public async Task <IActionResult> Create(PageForwardDetailViewModel model) { if (!ModelState.IsValid) { return(View("create", model) .WithWarning("Info", "Validation error, cannot be saved.")); } await Mediator.Send(new CreatePageForwardCommand { ProjectId = model.ProjectId, Mask = model.Mask, DestinationUrl = model.DestinationUrl, SourceId = model.SourceId, Type = model.Type }); return(RedirectToAction("Index") .WithSuccess("Page forward", "Created successfully.")); }
public async Task <IActionResult> Update(PageForwardDetailViewModel model) { if (!ModelState.IsValid) { return(RedirectToAction("Update", new { id = model.Id.Value }) .WithWarning("Invalid data.", "Cannot be saved.")); } await Mediator.Send(new UpdatePageForwardCommand { Id = model.Id.Value, ProjectId = model.ProjectId, Mask = model.Mask, DestinationUrl = model.DestinationUrl, SourceId = model.SourceId, Type = model.Type }); return(RedirectToAction("Index") .WithSuccess("Page forward", "Updated successfully.")); }