예제 #1
0
        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());
            }
        }
예제 #2
0
        public ViewResult Upload(DocumentUploadViewModel model)
        {
            if (ModelState.IsValid)
            {
                string fileFullName = System.IO.Path.GetFileName(model.uploadFile.FileName);
                string relativePath = DirectoryPathHelper.GetRelativePath(fileFullName, Server.MapPath);
                string absolutePath = Server.MapPath(relativePath);

                model.uploadFile.SaveAs(absolutePath);

                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());
            }
        }