public async Task <IFormResult <Post> > UpdateItem(Post item) { var user = await _userManager.GetUserAsync(_httpContextAccessor.HttpContext.User); var existingPost = await _dbContext.Posts.AsNoTracking().FirstOrDefaultAsync(p => p.Id == item.Id); item.BlogId = item.Blog.Id; item.Blog = null; item.CategoryId = item.Category.Id; item.Category = null; item.CreatedBy = user.Id; item.CreatedOn = DateTime.Now; item.Status = existingPost.Status; var entity = _blogMapper.Map <Models.Post>(item); _dbContext.UpdateGraph(entity, mapping => mapping.AssociatedCollection(p => p.Tags)); await _dbContext.SaveChangesAsync(); var post = await GetItem(item.Id.ToString()); var result = new FormResult <Post>(post) { IsSucceeded = true, SuccessMessage = $"Post has been updated" }; return(await Task.FromResult(result)); }