public async Task <IActionResult> Edit(int id, AdministrationBlogsViewModel article) { if (!this.ModelState.IsValid) { return(this.View(article)); } await this.blogService.UpdateAsync(article); return(this.RedirectToAction(nameof(this.Index))); }
public async Task UpdateAsync(AdministrationBlogsViewModel model) { var blogToUpdate = await this.articleRepository .AllAsNoTrackingWithDeleted() .FirstOrDefaultAsync(x => x.Id == model.Id); blogToUpdate.Title = model.Title; blogToUpdate.AuthorName = model.AuthorName; blogToUpdate.Content = model.Content; blogToUpdate.DeletedOn = model.DeletedOn; blogToUpdate.ModifiedOn = model.ModifiedOn; blogToUpdate.CreatedOn = model.CreatedOn; blogToUpdate.IsDeleted = model.IsDeleted; this.articleRepository.Update(blogToUpdate); await this.articleRepository.SaveChangesAsync(); }