public async Task UpdateAsync(int id, EditBlogPostInputModel input) { var blogPost = this.blogPostsRepository.All().FirstOrDefault(x => x.Id == id); blogPost.Title = input.Title; blogPost.BlogText = input.BlogText; await this.blogPostsRepository.SaveChangesAsync(); }
public async Task <IActionResult> Edit(int id, EditBlogPostInputModel input) { if (!this.ModelState.IsValid) { return(this.View(input)); } await this.blogPostsService.UpdateAsync(id, input); if (input == null) { return(this.RedirectToAction("NotFoundError", "Error")); } return(this.Redirect("/BlogPosts/All")); }