public ActionResult EditDocTemp(Template_Document template_document) { if (ModelState.IsValid) { db.Template_Document.Attach(template_document); db.ObjectStateManager.ChangeObjectState(template_document, EntityState.Modified); db.SaveChanges(); LogHelper.writeToStudentLog(new string[] { CookieHelper.Username }, (template_document.TemplateDoc_Id + " Template Document is Edited "), LogHelper.LOG_DELETE, LogHelper.SECTION_DOCUMENT); } ViewBag.Course_Id = new SelectList(db.Courses, "Course_Id", "Course_Name", template_document.Course_Id); NotificationHandler.setNotification(NotificationHandler.NOTY_SUCCESS, "Template Was Modified Successfully!"); return RedirectToAction("ShowAllDocumentTemplates"); }
public ActionResult UploadFileTemp(FormCollection fc, HttpPostedFileBase file) { int CourseId = Convert.ToInt32(fc["Course_Id"]); int UniId = Convert.ToInt32(fc["Uni_Id"]); string comment = (fc["comment"]); string formname = (fc["formname"]); Template_Document appDoc = new Template_Document(); if (file != null) { string pathToCreate; pathToCreate = TEMPLATE_APPLICATION_PATH + UniId + '_' + CourseId; // create / update folder fileName = Path.GetFileName(file.FileName); //path = Path.Combine(Server.MapPath(pathToCreate), fileName); //file.SaveAs(path); string fileToCreate = pathToCreate + '/' + file.FileName; //appDoc.Path = Path.Combine(Server.MapPath(pathToCreate)); appDoc.Path = pathToCreate; uploadAWS(fileToCreate, file); } else // Template with no downloadable form { fileName = "No File"; } // Update object of application document file appDoc.Course_Id = CourseId; appDoc.Form_Name = formname; appDoc.UploadedOn = System.DateTime.Now; appDoc.FileName = fileName; appDoc.UploadedBy = CookieHelper.Username; appDoc.Comment = comment; if (ModelState.IsValid) { db.Template_Document.AddObject(appDoc); db.SaveChanges(); LogHelper.writeToStudentLog(new string[] { CookieHelper.Username }, (" Uploaded file To " + appDoc.TemplateDoc_Id), LogHelper.LOG_CREATE, LogHelper.SECTION_DOCUMENT); NotificationHandler.setNotification(NotificationHandler.NOTY_SUCCESS, "Template was uploaded successfully!"); return View("Refresh"); } //TempData[SUCCESS_EDIT] = true; return RedirectToAction("ShowAllDocumentTemplates"); }