public ViewResult Create(DocumentCreateViewModel model) { if (ModelState.IsValid) { string fileFullName = model.Name + ".docx"; string relativePath = DirectoryPathHelper.GetRelativePath(fileFullName, Server.MapPath); string absolutePath = Server.MapPath(relativePath); CreateDocumentHelper.Create(absolutePath, model.Content); DocxToPdfHelper.Convert(absolutePath); Author author = repository.Authors.Single(a => a.Login == UserName); Document doc = new Document() { Author = author, Date = DateTime.Now, Name = model.Name, Url = relativePath }; repository.AddDocument(doc); return(View("Message", doc)); } else { return(View()); } }
public async Task AddDocument(DocumentDTO documentDTO) { var documentToAdd = new Document() { ID = documentDTO.ID, ParentID = documentDTO.Parent?.ID, Text = documentDTO.Text, Title = documentDTO.Title }; await documentsRepository.AddDocument(documentToAdd); }
public ActionResult Add(AddDocumentViewModel model) { if (ModelState.IsValid) { Document d = new Document(model.Name, DateTime.Now.Date, User.Identity.Name, TagsToString(model.Tags)); documentsRepository.AddDocument(d); return(RedirectToAction("List")); } else { ModelState.AddModelError("", "Данные введены некорректно"); return(View()); } }
public AttachmentsSaveStatus AddDocument(int CaseID, long?SessionID, vw_Documents Document) { if (FoldersRepository.DocumentsOverFlowNumber(Document.FolderID)) { return(AttachmentsSaveStatus.NumberOfDocumentOverFlow); } else { if (SessionID.HasValue) { Document.FolderID = FoldersRepository.SessionParentFolder(CaseID, SessionID.Value); } else if (!Document.FolderID.HasValue) { Document.FolderID = FoldersRepository.CaseParentFolder(CaseID); } return(DocumentsRepository.AddDocument(CaseID, SessionID, Document)); } }
public async Task <ResponseDto <string> > AddDocument(ClaimsPrincipal user, IFormFile document, int caseId) { Case caseFromDb = await _casesRepository.GetCaseById(caseId); ResponseDto <string> response = DocumentsValidator.ValidateAddDocument(caseFromDb, document, user); string filePath = GetAvailablePath(_documentsFolderPath, document.FileName); Document documentToAdd = new Document { Path = filePath, Status = Status.Sent, Case = caseFromDb }; try { using (var fs = new FileStream(filePath, FileMode.Create)) { await document.CopyToAsync(fs); } } catch { response.AddError(DocumentErrors.CannotSave); return(response); } try { await _documentsRepository.AddDocument(documentToAdd); var split = filePath.Split('\\'); response.Value = string.Join('/', split.Skip(split.Length - 2)); return(response); } catch { File.Delete(filePath); response.AddError(DocumentErrors.InfoSaveFailed); return(response); } }
public ActionResult Add(Document doc) { repo.AddDocument(doc); return(View("List", repo.GetDocument(doc.DocId))); }