public async Task <ActionResult> Send(SuggestionCommentSaveVM vm) { if (!ModelState.IsValid) { ModelState.AddModelError("GeneralError", "Form values are not valid!"); return(RedirectToAction("DetailCommentCallBack", "Suggestion", vm)); } var user = await _userManager.FindByNameAsync(User.Identity.Name); bool isSuggestionExist = await _suggestionService.AnyAsync(vm.SuggestionId); if (isSuggestionExist && user != null) { var result = await _service.AddAsync(vm, user.Id); if (!result.IsSuccessful) { if (result.Messages.Any()) { foreach (var error in result.Messages) { ModelState.AddModelError("GeneralError", error); } } return(RedirectToAction("DetailCommentCallBack", "Suggestion", vm)); } } else { ModelState.AddModelError("GeneralError", "Comment couldnt posted!"); return(RedirectToAction("DetailCommentCallBack", "Suggestion", vm)); } return(RedirectToAction("Detail", "Suggestion", new { id = vm.SuggestionId })); }
public async Task <ActionResult <SuggestionDetailVM> > DetailCommentCallBack(SuggestionCommentSaveVM vm) { ViewData["CommentFormData"] = vm; return(View("Detail", await GetSuggestion(vm.SuggestionId))); }