示例#1
0
        public FileTemp InsertAttachment(FileTemp attachment, bool dbStore)
        {
            attachment.MediaType = attachment.MediaType.EmptyNull();
            attachment.MediaType = attachment.MediaType.Truncate(20);

            attachment.FileName = attachment.FileName.Truncate(100);

            //Document document = _documentRepository.Create();

            var contentFile = new ContentFile()
            {
                FileName    = attachment.FileName,
                FileContent = Convert.ToBase64String(attachment.FileBinary)
            };

            attachment.FileContent = contentFile.ToXml();
            _tempFileRepository.Add(attachment);
            _work.commit();

            if (!dbStore)
            {
                SaveDocumentInFile(attachment.Id, attachment.FileBinary, attachment.MediaType);
            }

            return(attachment);
        }
示例#2
0
 public HttpResponseMessage Post(int id, Attachement attachement)
 {
     if (id != attachement.MailId)
     {
         return(Request.CreateResponse(HttpStatusCode.BadRequest));
     }
     if (_attachementRepository.Add(attachement))
     {
         return(Request.CreateResponse(HttpStatusCode.OK));
     }
     return(Request.CreateResponse(HttpStatusCode.InternalServerError));
 }