Exemplo n.º 1
0
        public static FormTable CreateFrom(IFormTableUpdatable fields)
        {
            fields.ThrowIfNull(nameof(fields));

            var formId         = Guid.NewGuid();
            var htmlTemplateId = Guid.NewGuid();
            var createdDate    = DateTimeOffset.Now;

            return(new FormTable(formId)
            {
                Name = fields.Name,
                Description = fields.Description,
                //UploadInterval = fields.UploadInterval,
                UploadWeekOfMonth = fields.UploadWeekOfMonth,
                UploadDayOfWeek = fields.UploadDayOfWeek,
                IsEnabled = fields.IsEnabled,
                HtmlTemplateId = htmlTemplateId,
                HtmlTemplate = new FormHtmlTemplate(formId, htmlTemplateId)
                {
                    FormName = fields.Name,
                    CreatedDate = createdDate
                },
                CreatedDate = createdDate
            });
        }
Exemplo n.º 2
0
        public void Update(IFormTableUpdatable fields, out List <UpdatedField> updated)
        {
            fields.ThrowIfNull(nameof(fields));

            updated = new List <UpdatedField>();

            if (Name != fields.Name && fields.Name.IsNotNullOrWhiteSpace())
            {
                updated.Add(new UpdatedField
                {
                    FieldName = nameof(Name),
                    OldValue  = Name,
                    NewValue  = fields.Name
                });

                Name = fields.Name;
            }

            if (Description != fields.Description)
            {
                updated.Add(new UpdatedField
                {
                    FieldName = nameof(Description),
                    OldValue  = Description,
                    NewValue  = fields.Description
                });

                Description = fields.Description;
            }

            // NOTE(jhlee): 실적 업로드 주기가 변경 되면 데이터 조회/확인 취소 처리에 문제가 생기므로 변경 불가능하도록 수정함.
            //if (UploadInterval != fields.UploadInterval)
            //{
            //    updated.Add(new UpdatedField
            //    {
            //        FieldName = nameof(UploadInterval),
            //        OldValue = UploadInterval,
            //        NewValue = fields.UploadInterval
            //    });

            //    UploadInterval = fields.UploadInterval;
            //}

            if (UploadWeekOfMonth != fields.UploadWeekOfMonth)
            {
                updated.Add(new UpdatedField
                {
                    FieldName = nameof(UploadWeekOfMonth),
                    OldValue  = UploadWeekOfMonth,
                    NewValue  = fields.UploadWeekOfMonth
                });

                UploadWeekOfMonth = fields.UploadWeekOfMonth;
            }

            if (UploadDayOfWeek != fields.UploadDayOfWeek)
            {
                updated.Add(new UpdatedField
                {
                    FieldName = nameof(UploadDayOfWeek),
                    OldValue  = UploadDayOfWeek,
                    NewValue  = fields.UploadDayOfWeek
                });

                UploadDayOfWeek = fields.UploadDayOfWeek;
            }

            if (IsEnabled != fields.IsEnabled)
            {
                updated.Add(new UpdatedField
                {
                    FieldName = nameof(IsEnabled),
                    OldValue  = IsEnabled,
                    NewValue  = fields.IsEnabled
                });

                IsEnabled = fields.IsEnabled;
            }

            if (updated.Any())
            {
                UpdatedDate = DateTimeOffset.Now;

                Validate();
            }
        }