public async Task <IActionResult> Edit(ExplicitAddRuleEditModel model) { var typiconEntity = QueryProcessor.Process(GetTypiconEntityByChildQuery(model.Id)); model.Mode = ModelMode.Edit; TryValidateModel(model); if (ModelState.IsValid && typiconEntity.Success && IsAuthorizedToEdit(typiconEntity.Value)) { var command = new EditExplicitAddRuleCommand(model.Id, model.Date, model.RuleDefinition); await CommandProcessor.ExecuteAsync(command); return(RedirectToAction(nameof(Index), new { id = typiconEntity.Value.Id })); } ViewBag.TypiconId = typiconEntity.Value.Id.ToString(); return(View(model)); }
public async Task <IActionResult> Create(ExplicitAddRuleEditModel model) { var typiconEntity = QueryProcessor.Process(new TypiconEntityQuery(model.Id)); model.Mode = ModelMode.Create; TryValidateModel(model); if (ModelState.IsValid && typiconEntity != null && IsAuthorizedToEdit(typiconEntity)) { var command = new CreateExplicitAddRuleCommand(model.Id, model.Date, model.RuleDefinition); await CommandProcessor.ExecuteAsync(command); return(RedirectToAction(nameof(Index), new { id = typiconEntity.Id })); } return(View(model)); }