Ejemplo n.º 1
0
        protected override TriodionRule Create(CreateRuleCommandBase <TriodionRule> command, TypiconVersion typiconVersion)
        {
            var c = command as CreateTriodionRuleCommand;

            var entity = new TriodionRule
            {
                TypiconVersion    = typiconVersion,
                TemplateId        = c.TemplateId,
                DaysFromEaster    = c.DaysFromEaster,
                IsTransparent     = c.IsTransparent,
                RuleDefinition    = c.RuleDefinition,
                ModRuleDefinition = c.ModRuleDefinition
            };

            //Синхронизируем Переменные Устава
            //entity.SyncRuleVariables(SerializerRoot);
            //entity.SyncModRuleVariables(SerializerRoot);

            foreach (var i in c.DayWorshipIds)
            {
                entity.DayRuleWorships.Add(new DayRuleWorship()
                {
                    DayRuleId = entity.Id, DayWorshipId = i.Id, Order = i.Order
                });
            }

            return(entity);
        }
Ejemplo n.º 2
0
        protected override PrintWeekTemplate Create(CreateRuleCommandBase <PrintWeekTemplate> command, TypiconVersion typiconVersion)
        {
            var c = command as CreatePrintWeekTemplateCommand;

            var entity = new PrintWeekTemplate()
            {
                DaysPerPage    = c.DaysPerPage,
                PrintFile      = c.PrintFile,
                PrintFileName  = c.PrintFileName,
                TypiconVersion = typiconVersion
            };

            return(entity);
        }
Ejemplo n.º 3
0
        protected override ExplicitAddRule Create(CreateRuleCommandBase <ExplicitAddRule> command, TypiconVersion typiconVersion)
        {
            var c = command as CreateExplicitAddRuleCommand;

            var entity = new ExplicitAddRule()
            {
                Date           = c.Date,
                RuleDefinition = c.RuleDefinition,
                TypiconVersion = typiconVersion,
            };

            //entity.SyncRuleVariables(SerializerRoot);

            return(entity);
        }
        protected override CommonRule Create(CreateRuleCommandBase <CommonRule> command, TypiconVersion typiconVersion)
        {
            var c = command as CreateCommonRuleCommand;

            var entity = new CommonRule()
            {
                Name           = c.Name,
                RuleDefinition = c.RuleDefinition,
                TypiconVersion = typiconVersion
            };

            //entity.SyncRuleVariables(SerializerRoot);

            return(entity);
        }
Ejemplo n.º 5
0
        protected async Task <Result> ExecuteAsync(CreateRuleCommandBase <T> command)
        {
            var version = DbContext.Set <TypiconVersion>()
                          .FirstOrDefault(c => c.TypiconId == command.TypiconId &&
                                          c.BDate == null && c.EDate == null);

            if (version == null)
            {
                return(Result.Fail($"Версия Устава с Id {command.TypiconId} не найдена."));
            }

            var obj = Create(command, version);

            DbContext.Set <T>().Add(obj);

            version.IsModified = true;

            //await DbContext.SaveChangesAsync();

            return(Result.Ok());
        }
        protected override PrintDayTemplate Create(CreateRuleCommandBase <PrintDayTemplate> command, TypiconVersion typiconVersion)
        {
            var c = command as CreatePrintDayTemplateCommand;

            var entity = new PrintDayTemplate()
            {
                Name           = c.Name,
                Number         = c.Number,
                Icon           = c.Icon,
                IsRed          = c.IsRed,
                PrintFile      = c.PrintFile,
                PrintFileName  = c.PrintFileName,
                TypiconVersion = typiconVersion
            };

            if (c.IsDefault)
            {
                typiconVersion.PrintDayDefaultTemplate = entity;
            }

            return(entity);
        }
        protected override Sign Create(CreateRuleCommandBase <Sign> command, TypiconVersion typiconVersion)
        {
            var c = command as CreateSignCommand;

            var entity = new Sign()
            {
                IsAddition        = c.IsAddition,
                ModRuleDefinition = c.ModRuleDefinition,
                SignName          = new ItemText(new ItemTextUnit(CommonConstants.DefaultLanguage, c.Name)),
                PrintTemplateId   = c.PrintTemplateId,
                Priority          = c.Priority,
                RuleDefinition    = c.RuleDefinition,
                TypiconVersion    = typiconVersion,
                TemplateId        = c.TemplateId
            };

            //Синхронизируем Переменные Устава
            //entity.SyncRuleVariables(SerializerRoot);
            //entity.SyncModRuleVariables(SerializerRoot);

            return(entity);
        }
Ejemplo n.º 8
0
 protected abstract T Create(CreateRuleCommandBase <T> command, TypiconVersion typiconVersion);