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 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);
     }
 }
        private Result Delete(AuthorizedUsers user)
        {
            var result = new Result();

            try
            {
                if (string.IsNullOrEmpty(user.UserId))
                {
                    throw new Exception("UserId is required to delete.");
                }
                cusRelContext.Entry(user).State = EntityState.Deleted;
                var count = SaveChanges();
                if (count > 0)
                {
                    result.SetOK();
                }
            }
            catch (Exception e)
            {
                result.SetFail(e);
            }
            return(result);
        }