public async Task <IActionResult> CommentUpdatePartial(CommentUpdateViewModel commentUpdateViewModel) { var commentUpdateDto = _mapper.Map <CommentUpdateDto>(commentUpdateViewModel); var result = await _bookCommentService.UpdateComment(commentUpdateDto); var comments = await _bookCommentService.GetAllComment(); if (result.ResultStatus == ResultStatus.Success) { return(RedirectToAction("Index")); } else { ModelState.AddModelError("", result.Message); return(View(commentUpdateViewModel)); } }
public async Task <IActionResult> UpdatePublicationComment([FromRoute] int blogId, [FromRoute] int publicationId, [FromRoute] int commentId, [FromBody] CommentUpdateViewModel model) { var message = await _context.Messages.Include(m => m.ChildMessages).Include(m => m.SenderProfile).SingleOrDefaultAsync(m => m.BlogId == blogId && m.PublicationId == publicationId && m.Id == commentId); if (message == null) { return(NotFound()); } if (message.SenderSub == User.FindFirst("sub").Value) { return(Forbid()); } message.Subject = model.Subject; message.Body = model.Body; await _context.SaveChangesAsync(); return(Ok(message.ToCommentViewModel())); }