public async Task <IActionResult> Edit(MenologyRuleEditModel model) { var typiconEntity = QueryProcessor.Process(new TypiconEntityByMenologyRuleQuery(model.Id)); if (ModelState.IsValid && typiconEntity.Success && IsAuthorizedToEdit(typiconEntity.Value)) { var command = new EditMenologyRuleCommand(model.Id, model.DayWorships.Select(c => (c.WorshipId, c.Order)), model.TemplateId, model.IsAddition, model.RuleDefinition, model.ModRuleDefinition); await CommandProcessor.ExecuteAsync(command); return((ViewBag.IsFromSchedule is bool b == true) ? RedirectToAction(nameof(ScheduleSettingsController.Index), "ScheduleSettings", new { id = typiconEntity.Value.Id }) : RedirectToAction(nameof(Index), new { id = typiconEntity.Value.Id })); } ViewBag.Signs = QueryProcessor.GetSigns(typiconEntity.Value.Id, DEFAULT_LANGUAGE); ViewBag.TypiconId = typiconEntity.Value.Id.ToString(); return(View(model)); }
public IActionResult Edit(int id, bool fromSchedule = false) { if (id < 1) { return(NotFound()); } var typiconEntity = QueryProcessor.Process(new TypiconEntityByMenologyRuleQuery(id)); if (typiconEntity.Success && IsAuthorizedToEdit(typiconEntity.Value)) { ViewBag.Signs = QueryProcessor.GetSigns(typiconEntity.Value.Id, DEFAULT_LANGUAGE); ViewBag.TypiconId = typiconEntity.Value.Id.ToString(); ViewBag.IsFromSchedule = fromSchedule; var found = QueryProcessor.Process(new MenologyRuleEditQuery(id, DEFAULT_LANGUAGE)); if (found.Success) { return(View(found.Value)); } } return(NotFound()); }
public async Task <IActionResult> Create(TriodionRuleCreateEditModel 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 CreateTriodionRuleCommand(model.Id, model.DayWorships.Select(c => (c.WorshipId, c.Order)), model.TemplateId, model.DaysFromEaster, model.IsTransparent, model.RuleDefinition, model.ModRuleDefinition); await CommandProcessor.ExecuteAsync(command); return(RedirectToAction(nameof(Index), new { id = typiconEntity.Id })); } ViewBag.Signs = QueryProcessor.GetSigns(typiconEntity.Id, DEFAULT_LANGUAGE); return(View(model)); }
public IActionResult Edit(int id, bool fromSchedule = false) => Perform(() => QueryProcessor.Process(new SignEditQuery(id)), sign => { ViewBag.Signs = QueryProcessor.GetSigns(sign.Value.TypiconId, DEFAULT_LANGUAGE, id); ViewBag.PrintTemplates = QueryProcessor.GetPrintTemplates(sign.Value.TypiconId); ViewBag.IsFromSchedule = fromSchedule; return(View(sign.Value)); });
public IActionResult Create(int id) { if (id < 1) { return(NotFound()); } var typiconEntity = QueryProcessor.Process(new TypiconEntityQuery(id)); if (typiconEntity != null && IsAuthorizedToEdit(typiconEntity)) { ViewBag.Signs = QueryProcessor.GetSigns(typiconEntity.Id, DEFAULT_LANGUAGE); return(View(new MenologyRuleCreateModel())); } return(Unauthorized()); }