public async Task <IActionResult> Create(CreateSmileyInput input) { if (ModelState.IsValid) { var serviceResponse = await SmileyRepository.Create(input); return(await ForumViewResult.RedirectFromService(this, serviceResponse, FailureCallback)); } return(await FailureCallback()); async Task <IActionResult> FailureCallback() { var viewModel = new ViewModels.CreatePage { Code = input.Code, Thought = input.Thought }; return(await ForumViewResult.ViewResult(this, viewModel)); } }
public async Task <IActionResult> Create(ControllerModels.Smileys.CreateSmileyInput input) { if (ModelState.IsValid) { var result = await SmileyRepository.Create(input); ModelState.AddModelErrors(result.Errors); if (ModelState.IsValid) { TempData[Constants.InternalKeys.StatusMessage] = $"Smiley '{input.File.FileName}' was added with code '{input.Code}'."; var referrer = ForumViewResult.GetReferrer(this); return(Redirect(referrer)); } } var viewModel = new ViewModels.CreatePage { Code = input.Code, Thought = input.Thought }; return(await ForumViewResult.ViewResult(this, viewModel)); }