示例#1
0
        /// <summary>
        /// 대시보드 테이블 html 양식을 업데이트한다.
        /// </summary>
        public FormHtmlTemplate UpdateFormHtmlTemplate(Guid formId, Guid templateId, IFormHtmlTemplateUpdatable fields)
        {
            using (var repo = new FormTableRepository())
            {
                var template = repo.SelectFormHtmlTemplate(formId, templateId);
                if (template == null)
                {
                    throw new ObjectNotFoundException($"업데이트 할 대상 대시보드 양식을 찾을 수 없습니다.\r\n양식 ID: \"{templateId}\"");
                }

                List <UpdatedField> updated = null;
                template.Update(fields, out updated);

                if (repo.UpdateFormHtmlTemplate(template))
                {
                    logger.Info($"대시보드 양식이 업데이트 되었습니다. 대시보드: \"{template.FormName}\""
                                + $"\r\n\r\n"
                                + $"updated: {UpdatedField.Print(updated)}"
                                + $"\r\n\r\n"
                                + $"{template}");

                    return(template);
                }

                return(null);
            }
        }
示例#2
0
        public static FormHtmlTemplate CreateFrom(IFormHtmlTemplateUpdatable fields)
        {
            fields.ThrowIfNull(nameof(fields));

            return(new FormHtmlTemplate(Guid.NewGuid(), Guid.NewGuid())
            {
                Description = fields.Description,
                ScriptContent = fields.ScriptContent,
                HtmlContent = fields.HtmlContent,
                StyleContent = fields.StyleContent,
                CreatedDate = DateTimeOffset.Now
            });
        }
示例#3
0
        public void Update(IFormHtmlTemplateUpdatable fields)
        {
            List <UpdatedField> updated = null;

            this.Update(fields, out updated);
        }
示例#4
0
        public void Update(IFormHtmlTemplateUpdatable fields, out List <UpdatedField> updated)
        {
            fields.ThrowIfNull(nameof(fields));

            updated = new List <UpdatedField>();

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

                Description = fields.Description;
            }

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

                ScriptContent = fields.ScriptContent;
            }

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

                HtmlContent = fields.HtmlContent;
            }

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

                StyleContent = fields.StyleContent;
            }

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

                Validate();
            }
        }