public DocumentViewModel GetDocumentViewModel(Document doc) { var docViewModel = new DocumentViewModel(); docViewModel.Id = doc.Id; docViewModel.Name = doc.Name; docViewModel.Date = doc.Date; docViewModel.Author = doc.Author; docViewModel.OriginalFileName = doc.OriginalFileName; docViewModel.UniqueFileName = doc.UniqueFileName; return docViewModel; }
public Document GetDocumentDomainModel(DocumentViewModel docViewModel) { var doc = new Document(); doc.Id = docViewModel.Id; doc.Name = docViewModel.Name; doc.Date = docViewModel.Date; doc.Author = docViewModel.Author; doc.OriginalFileName = docViewModel.OriginalFileName; doc.UniqueFileName = docViewModel.UniqueFileName; return doc; }
public ActionResult CreateDocument(DocumentViewModel docViewModel, HttpPostedFileBase file) { if (ModelState.IsValid) { if (file == null) return View("CreateDocumentForm", docViewModel); docViewModel.Date = DateTime.Now; docViewModel.Author = User.Identity.Name; docViewModel.OriginalFileName = Path.GetFileName(file.FileName); docViewModel.UniqueFileName = fileService.SaveFile(file); var docDomainModel = mapper.GetDocumentDomainModel(docViewModel); docService.AddDocument(docDomainModel); return RedirectToAction("Index"); } else return View("CreateDocumentForm", docViewModel); }
public ActionResult CreateDocument() { var newDoc = new DocumentViewModel(); return View("CreateDocumentForm", newDoc); }