public ActionResult Document(OtherDocumentsViewModel documentViewModel) { if (ModelState.IsValid) { var uploads = Path.Combine(Directory.GetCurrentDirectory(), "wwwroot\\uploads"); var fileName = Path.GetFileName(documentViewModel.File.FileName); var filePath = Path.Combine(uploads, fileName); using (FileStream file = new FileStream(filePath, FileMode.Create)) { documentViewModel.File.CopyTo(file); file.Close(); } Document document = new Document { Idcandidate = HttpContext.Session.GetInt32("IdCandidate"), Url = $"\\uploads\\{fileName}", Iddocumenttype = documentViewModel.Iddocumenttype, }; db.Document.Add(document); db.SaveChanges(); return(RedirectToAction("Document", "Document")); } documentViewModel.DocumentTypeList = new SelectList(db.Documenttype.Where(d => d.SubType == 2).ToList(), "Iddocumenttype", "Name", 1); return(View(documentViewModel)); }
public ActionResult Document() { OtherDocumentsViewModel experience = new OtherDocumentsViewModel { DocumentTypeList = new SelectList(db.Documenttype.Where(d => d.SubType == 2).ToList(), "Iddocumenttype", "Name", 1) }; return(View(experience)); }