示例#1
0
        public void Update(IFormTableSectionUpdatable fields, out List <UpdatedField> updated)
        {
            fields.ThrowIfNull(nameof(fields));

            updated = new List <UpdatedField>();

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

                FormSectionName = fields.FormSectionName;
            }

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

                ScriptVariable = fields.ScriptVariable;
            }

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

                IsEnabled = fields.IsEnabled;
            }

            var oldUploaders = FileSourceUploaders.Keys.OrderBy(o => o).ToArray();
            var newUploaders = fields.FileSourceUploaders.OrderBy(o => o).ToArray();

            if (!oldUploaders.SequenceEqual(newUploaders))
            {
                updated.Add(new UpdatedField
                {
                    FieldName = nameof(FileSourceUploaders),
                    OldValue  = oldUploaders,
                    NewValue  = newUploaders
                });

                // service 단에서 업데이트 처리함.
            }


            if (fields.FileTemplate != null)
            {
                if (FileTemplate == null)
                {
                    // service 단에서 채워줘야 함.
                }
                else
                {
                    List <UpdatedField> temp = null;
                    FileTemplate.Update(fields.FileTemplate, out temp);

                    updated.AddRange(temp);
                }
            }

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

                Validate();
            }
        }