public ActionResult RemStudent(int studentId, int projectID) { if (ExtFunctions.checkStudent()) { // check if student is in the set of students returned by query if (!ExtFunctions.worksOnProject(projectID)) { return RedirectToAction("Index", "Home"); } } db.delete_Student_from_Project(studentId, projectID); return RedirectToAction("AddRemStudents", new { ProjectID = projectID }); }
public ActionResult EditProject(ProjectModel model, string btnSubmit) { if (ExtFunctions.checkStudent()) { // check if student is in the set of students returned by query if (!ExtFunctions.worksOnProject(model.projectID)) { return RedirectToAction("Index", "Home"); } } // call update project SPROC db.update_Project(model.projectID, model.project.Name, model.project.Description, model.project.Image_Gallery, model.project.DateAdded, DateTime.Now, model.project.Active); // return to project's profile page return RedirectToAction("EditProject", new { id = model.projectID }); }
public ActionResult AddRemStudents(int? ProjectID) { if (ProjectID.HasValue) { if (ExtFunctions.checkStudent()) { // check if student is in the set of students returned by query if (!ExtFunctions.worksOnProject(ProjectID)) { return RedirectToAction("Index", "Home"); } } var projectStudents = db.get_Students_WorkingON_projects(ProjectID); var model = new Models.AddStudentModel() { studentsOnProject = projectStudents, projectID = (int)ProjectID }; return View(model); } return RedirectToAction("Index", "Home"); }
public ActionResult AddStudent(AddStudentModel model) { if (ExtFunctions.checkStudent()) { // check if student is in the set of students returned by query if (!ExtFunctions.worksOnProject(model.projectID)) { return RedirectToAction("Index", "Home"); } } try { var student = db.get_Student_ByEmail(model.StudentEmail).FirstOrDefault(); db.add_Student_to_Project(student.StudentID, model.projectID); return RedirectToAction("AddRemStudents", new { ProjectID = model.projectID }); } catch { return RedirectToAction("AddRemStudents", new { ProjectID = model.projectID }); } }
public ActionResult EditProject(int? id) { if (!id.HasValue) return RedirectToAction("Index", "Home"); if (ExtFunctions.checkStudent()) { // check if student is in the set of students returned by query if (!ExtFunctions.worksOnProject(id)) { return RedirectToAction("Index", "Home"); } } var projectModel = db.get_Project_details(id).First(); var extRecs = db.get_Project_Ext_Resources(id); var ML_Parts = db.get_Project_MLParts(id); var ML_Tools = db.get_Project_MLTools(id); List<SelectListItem> selectListRecs = new List<SelectListItem>(); List<SelectListItem> selectListActiveRecs = new List<SelectListItem>(); List<SelectListItem> selectListParts = new List<SelectListItem>(); List<SelectListItem> selectListActiveParts = new List<SelectListItem>(); List<SelectListItem> selectListTools = new List<SelectListItem>(); List<SelectListItem> selectListActiveTools = new List<SelectListItem>(); foreach (var extRec in extRecs) { if (extRec.FLAG == 0) { selectListRecs.Add(new SelectListItem() { Text = extRec.Name, Value = extRec.ID.ToString(), Selected = false }); } else { selectListActiveRecs.Add(new SelectListItem() { Text = extRec.Name, Value = extRec.ID.ToString(), Selected = false }); } } foreach (var MLPart in ML_Parts) { if (MLPart.FLAG == 0) { selectListParts.Add(new SelectListItem() { Text = MLPart.Name, Value = MLPart.ID.ToString(), Selected = false }); } else { selectListActiveParts.Add(new SelectListItem() { Text = MLPart.Name, Value = MLPart.ID.ToString(), Selected = false }); } } foreach (var MLTool in ML_Tools) { if (MLTool.FLAG == 0) { selectListTools.Add(new SelectListItem() { Text = MLTool.Name, Value = MLTool.ID.ToString(), Selected = false }); } else { selectListActiveTools.Add(new SelectListItem() { Text = MLTool.Name, Value = MLTool.ID.ToString(), Selected = false }); } } var projectRecs = new Models.ProjectExtRec() { }; var model = new Models.ProjectModel() { projectID = projectModel.ID, project = projectModel, Project_MLParts = new ProjectMLParts() { CurrentMLParts = selectListActiveParts, MLParts = selectListParts }, Project_MLTools = new ProjectMakerLabTools() { CurrentMLTools = selectListActiveTools, MLTools = selectListTools }, projectRels = new ProjectExtRec() { ExtResources = selectListRecs, CurrentExtResources = selectListActiveRecs } }; return View(model); }
public ActionResult ProjectParts(ProjectModel model, string btnSubmit) { if (ExtFunctions.checkStudent()) { // check if student is in the set of students returned by query if (!ExtFunctions.worksOnProject(model.projectID)) { return RedirectToAction("Index", "Home"); } } switch (btnSubmit) { case "Add MLPart >>": // rearrange lists and return to edit project page try { foreach (var skill in model.Project_MLParts.selectedMLParts) { db.AddProject_ML_Part(model.projectID, Convert.ToInt32(skill)); } } catch { ModelState.AddModelError("Add Error", "You must select a MakerLab Part to be added"); } return RedirectToAction("EditProject", new { id = model.projectID }); case "<< Remove ML Part": // rearrange lists and return to edit project page try { foreach (var skill in model.Project_MLParts.selectedMLPartsToRemove) { db.removeProject_ML_PART(model.projectID, Convert.ToInt32(skill)); } } catch { ModelState.AddModelError("Remove Error", "You must select a MakerLab Part to be Removed"); } return RedirectToAction("EditProject", new { id = model.projectID }); case "Add ML Tool >>": // rearrange lists and return to edit project page try { foreach (var skill in model.Project_MLTools.selectedMLTools) { db.AddProject_ML_TOOL(model.projectID, Convert.ToInt32(skill)); } } catch { ModelState.AddModelError("Add Error", "You must select a MakerLab Tool to be added"); } return RedirectToAction("EditProject", new { id = model.projectID }); case "<< Remove ML Tool": // rearrange lists and return to edit project page try { foreach (var skill in model.Project_MLTools.selectedMLToolsToRemove) { db.removeProject_ML_TOOL(model.projectID, Convert.ToInt32(skill)); } } catch { ModelState.AddModelError("Remove Error", "You must select a MakerLab Tool to be Removed"); } return RedirectToAction("EditProject", new { id = model.projectID }); case "Add Resource >>": // rearrange lists and return to edit project page try { foreach (var skill in model.projectRels.selectedExtResources) { db.AddProject_ExtResource(model.projectID, Convert.ToInt32(skill)); } } catch { ModelState.AddModelError("Add Error", "You must select an extRec to be added"); } return RedirectToAction("EditProject", new { id = model.projectID }); case "<< Remove Resource": // rearrange lists and return to edit project page try { foreach (var skill in model.projectRels.selectedExtResourcesToRemove) { db.remove_Project_extResource(model.projectID, Convert.ToInt32(skill)); } } catch { ModelState.AddModelError("Remove Error", "You must select an extRec to be Removed"); } return RedirectToAction("EditProject", new { id = model.projectID }); default: break; } return RedirectToAction("EditProject", new { id = model.projectID }); }