예제 #1
0
        public IHttpActionResult GetNewDocFile(int docId)
        {
            var docFileKind = this.unitOfWork.DbContext.Set<DocFileKind>()
                .Single(fk => fk.Alias == "PrivateAttachedFile");

            DocFileDO docFile = new DocFileDO()
            {
                IsNew = true,
                DocFileKindId = docFileKind.DocFileKindId,
                File = null
            };

            return Ok(docFile);
        }
예제 #2
0
        public IHttpActionResult PostCreateDocFile(int docId, DocFileDO file)
        {
            using (var transaction = this.unitOfWork.BeginTransaction())
            {
                var doc = this.docRepository.Find(docId);
                var docFileTypes = this.unitOfWork.DbContext.Set<DocFileType>().ToList();

                var docFileType = docFileTypes.FirstOrDefault(e => e.Extention == Path.GetExtension(file.File.Name));
                if (docFileType == null)
                {
                    docFileType = docFileTypes.FirstOrDefault(e => e.Alias == "UnknownBinary");
                }

                doc.CreateDocFile(file.DocFileKindId, docFileType.DocFileTypeId, file.Name, file.File.Name, String.Empty, file.File.Key, this.userContext);

                this.unitOfWork.Save();
                transaction.Commit();
            }

            return Ok();
        }