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(); }
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")); }