Ejemplo n.º 1
0
        public async Task AddBlog(BlogAddInputViewModel blogAddModel, string userId)
        {
            var blog = this.mapper.Map <Blog>(blogAddModel);

            blog.CreatorId = userId;
            await this.db.Blogs.AddAsync(blog);

            await this.db.SaveChangesAsync();
        }
Ejemplo n.º 2
0
        public async Task <IActionResult> Add(BlogAddInputViewModel blogAddModel)
        {
            if (!this.ModelState.IsValid)
            {
                return(this.View(blogAddModel));
            }
            ;
            var userId = this.User.FindFirst(ClaimTypes.NameIdentifier).Value;

            await this.blogService.AddBlog(blogAddModel, userId);

            return(this.Redirect("/Blogs/All"));
        }