Ejemplo n.º 1
0
        public async Task <IActionResult> Edit(TriodionRuleCreateEditModel model)
        {
            var typiconEntity = QueryProcessor.Process(new TypiconEntityByTriodionRuleQuery(model.Id));

            model.Mode = ModelMode.Edit;

            TryValidateModel(model);

            if (ModelState.IsValid &&
                typiconEntity.Success &&
                IsAuthorizedToEdit(typiconEntity.Value))
            {
                var command = new EditTriodionRuleCommand(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((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));
        }
Ejemplo n.º 2
0
        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));
        }