private tblAttachmentsTemp cleanData(tblAttachmentsTemp attachment) { if (attachment.Base64Data != null) { var match = base64re.Match(attachment.Base64Data); if (match.Success) { attachment.Base64Data = match.Groups[2].Value; } } return(attachment); }
protected tblAttachmentsTemp GetAttachmentTemp(tblAttachmentsTemp attachmentTemp) { using (cusRelContext = new CusRelEntities()) { var attachment = (from a in cusRelContext.tblAttachmentsTemp where (attachmentTemp.Id > 0 && a.Id == attachmentTemp.Id) || (attachmentTemp.Id <= 0 && (attachmentTemp.AttachmentNum > 0 && a.AttachmentNum == attachmentTemp.AttachmentNum) && (attachmentTemp.FileName != "" && a.FileName == attachmentTemp.FileName) && (attachmentTemp.ScanId != "" && a.ScanId == attachmentTemp.ScanId)) select a).FirstOrDefault(); return(cleanData(attachment)); } }
protected bool UpdateAttachmentTemp(tblAttachmentsTemp attachment) { try { using (cusRelContext = new CusRelEntities()) { cusRelContext.tblAttachmentsTemp.Attach(attachment); cusRelContext.Entry(attachment).State = EntityState.Modified; return(cusRelContext.SaveChanges() == 1); } } catch (Exception e) { return(false); } }
protected bool DeleteAttachmentTemp(tblAttachmentsTemp attachment) { try { using (cusRelContext = new CusRelEntities()) { cusRelContext.tblAttachmentsTemp.Attach(attachment); cusRelContext.tblAttachmentsTemp.Remove(attachment); return(cusRelContext.SaveChanges() == 1); } } catch (Exception e) { return(false); } }
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); } }
public bool Save(tblAttachmentsTemp item) { return(UpdateAttachmentTemp(item)); }