Esempio n. 1
0
        /// <summary>
        /// Domain to data access converter for FileAttributes
        /// </summary>
        /// <param name="AuditDomainObject"></param>
        /// <param name="AuditRecord"></param>
        /// <returns></returns>
        public static Audit ConvertFileAttributes(AuditObject AuditDomainObject, Audit AuditRecord)
        {
            var recordsToDelete = new List<string>();
            foreach (var attachmentObject in AuditDomainObject.AuditAttributes.Where(P => P.Value is FileAuditAttributeObject))
            {
                var attachment = attachmentObject.Value as FileAuditAttributeObject;

                if (attachment != null)
                {
                    var fileAttribute = new FileAttribute
                                            {
                                                Key = attachmentObject.Key,
                                                DateCreated =
                                                    attachment.DateCreated == DateTime.MinValue
                                                        ? DateTime.Now
                                                        : attachment.DateCreated,
                                                DateDeleted = attachment.DateDeleted,
                                                DateUpdated = attachment.DateUpdated,
                                                FileName = attachment.Name,
                                                Extension = attachment.Extension,
                                                Value = attachment.Value
                                            };
                    AuditRecord.Attribute.Add(fileAttribute);
                }
                recordsToDelete.Add(attachmentObject.Key);
            }
            recordsToDelete.ForEach(I => AuditDomainObject.AuditAttributes.Remove(I));
            return AuditRecord;
        }
 /// <summary>
 /// Create a new FileAttribute object.
 /// </summary>
 /// <param name="id">Initial value of the Id property.</param>
 /// <param name="key">Initial value of the Key property.</param>
 /// <param name="dateCreated">Initial value of the DateCreated property.</param>
 /// <param name="value">Initial value of the Value property.</param>
 /// <param name="extension">Initial value of the Extension property.</param>
 /// <param name="fileName">Initial value of the FileName property.</param>
 public static FileAttribute CreateFileAttribute(global::System.Int32 id, global::System.String key, global::System.DateTime dateCreated, global::System.Byte[] value, global::System.String extension, global::System.String fileName)
 {
     FileAttribute fileAttribute = new FileAttribute();
     fileAttribute.Id = id;
     fileAttribute.Key = key;
     fileAttribute.DateCreated = dateCreated;
     fileAttribute.Value = value;
     fileAttribute.Extension = extension;
     fileAttribute.FileName = fileName;
     return fileAttribute;
 }