public async Task <IActionResult> Add(AddMovieCommentDTO addMovieCommentDTO) { try { if (ModelState.IsValid) { await _movieCommentService.AddComment(addMovieCommentDTO, User); TempData["AddCommentNote"] = "Your comment has been posted.It will show up after approval."; return(RedirectToAction("Details", "Movie", new { id = addMovieCommentDTO.MovieId })); } TempData["AddCommentError"] = "Please insert valid format!"; return(RedirectToAction("Details", "Movie", new { id = addMovieCommentDTO.MovieId })); } catch (FlowException ex) { TempData["AddCommentError"] = ex.Message; return(RedirectToAction("Details", "Movie", new { id = addMovieCommentDTO.MovieId })); } catch (Exception) { return(StatusCode(500)); } }
public async Task <IActionResult> AddComment(CommentAddViewModel commentAddViewModel) { if (ModelState.IsValid) { try { var commentAddDto = _mapper.Map <CommentAddMovieDto>(commentAddViewModel); var result = await _movieCommentService.AddComment(commentAddDto); if (result.ResultStatus == ResultStatus.Success) { return(RedirectToAction("Details", new { Id = commentAddDto.MovieId })); } } catch (Exception exc) { return(RedirectToAction("PleaseEditComment")); } } return(View(commentAddViewModel)); }