public async Task <IActionResult> Create(CreateDeploymentPlanViewModel model) { if (!await _authorizationService.AuthorizeAsync(User, Permissions.ManageDeploymentPlan)) { return(Forbid()); } if (ModelState.IsValid) { if (String.IsNullOrWhiteSpace(model.Name)) { ModelState.AddModelError(nameof(CreateDeploymentPlanViewModel.Name), S["The name is mandatory."]); } } if (ModelState.IsValid) { var deploymentPlan = new DeploymentPlan { Name = model.Name }; _session.Save(deploymentPlan); return(RedirectToAction(nameof(Index))); } // If we got this far, something failed, redisplay form return(View(model)); }
public async Task <IActionResult> Create() { if (!await _authorizationService.AuthorizeAsync(User, Permissions.ManageDeploymentPlan)) { return(Forbid()); } var model = new CreateDeploymentPlanViewModel(); return(View(model)); }