Ejemplo n.º 1
0
 public static Attachment FromAttachment(tblAttachments Attachment)
 {
     return(new Attachment
     {
         Id = Attachment.AttachmentNum,
         Filename = Attachment.FileName,
         Data = Attachment.BinaryData,
         UploadedAt = Attachment.DateUploaded,
         UploadedBy = new User(Id: Attachment.UploadedBy),
         Description = Attachment.Description
     });
 }
 protected bool AllowAttachment(tblAttachmentsTemp attachment)
 {
     try
     {
         using (cusRelContext = new CusRelEntities())
         {
             var newAttachment = new tblAttachments();
             newAttachment.InjectFrom(new LoopInjection(new[] { "tblContacts" }), attachment);
             newAttachment.BinaryData = Convert.FromBase64String(attachment.Base64Data);
             cusRelContext.tblAttachments.Attach(newAttachment);
             cusRelContext.Entry(newAttachment).State = EntityState.Added;
             return(cusRelContext.SaveChanges() == 1);
         }
     }
     catch (Exception e)
     {
         return(false);
     }
 }