예제 #1
0
        public Int32 UploadFile(FileToUpload file)
        {
            try
            {
                string newPath = Path.Combine(filePath, file.FolderName);
                if (!Directory.Exists(newPath))
                {
                    Directory.CreateDirectory(newPath);
                }
                string fullPath = Path.Combine(newPath, file.FileName);
                file.FileAsByteArray = Convert.FromBase64String(file.FileAsBase64);

                using (var fs = new FileStream(fullPath, FileMode.Create))
                {
                    fs.Write(file.FileAsByteArray, 0, file.FileAsByteArray.Length);
                }

                dtoMailAttachment dtoA = new dtoMailAttachment();
                dtoA.Attachment = file.FileName;
                dtoA.MailId     = Convert.ToInt32(file.FolderName);
                return(mailAttachmentService.SaveAttachment(dtoA));
            }
            catch (Exception ex)
            {
                throw (ex);
            }
        }
예제 #2
0
 public Int32 SaveAttachment(dtoMailAttachment eMailAttach)
 {
     try
     {
         MailAttachment attch = Mapper.Map <MailAttachment>(eMailAttach);
         dataContext.MailAttachments.Add(attch);
         int retValue = dataContext.SaveChanges();
         dataContext = new MailManagerDBConnection();
         return(attch.AttachmentId);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
예제 #3
0
        public dtoMailAttachment GetAttachment(decimal id)
        {
            try
            {
                var Attachment = dataContext.MailAttachments.Find(id);

                dtoMailAttachment dtoAttachment = Mapper.Map <dtoMailAttachment>(Attachment);

                return(dtoAttachment);
            }
            catch (Exception ex)
            {
                throw ex;;
            }
        }