public ActionResult AddPolicyDocument() { var fullPath = Server.MapPath(@"~/PolicyDocuments/PolicyDocuments.txt"); var model = new UploadPolicyVM(); var ops = FileManager.CreatePolicyDocumentOperations(); var response = ops.GetAllCategories(fullPath); model.CreateCategoryList(response.Data); return View(model); }
public ActionResult AddPolicyDocument(UploadPolicyVM model) { var fullPath = Server.MapPath(@"~/PolicyDocuments/PolicyDocuments.txt"); var ops = FileManager.CreatePolicyDocumentOperations(); if (ModelState.IsValid) { var file = model.file; if (file.ContentLength > 0) { var directoryPath = Server.MapPath(@"~/PolicyDocuments"); file.SaveAs(String.Format(@"{0}\{1}", directoryPath, file.FileName)); var policyDoc = new PolicyDocument(); string extension = Path.GetExtension(file.FileName); //null ref - needs to be updated if (!model.NewCategory.IsEmpty()) { policyDoc.Category.CategoryName = model.NewCategory.ToUpper(); } else { policyDoc.Category.CategoryID = model.SelectedCategory; } policyDoc.Name = model.DocName; policyDoc.FilePath = file.FileName; ops.AddPolicyDocument(policyDoc, fullPath); return View("ConfirmationPage"); } } var response = ops.GetAllCategories(fullPath); model.CreateCategoryList(response.Data); return View(model); }