public ActionResult UpdateGrid(string hiddenSchoolFilter, string hiddenSchoolYearFilter) { try { dbTIREntities db = new dbTIREntities(); SiteUser siteUser = ((SiteUser)Session["SiteUser"]); StudentService studentService = new StudentService(siteUser, db); SchoolService schoolService = new SchoolService(siteUser, db); ModelServices modelService = new ModelServices(); ViewBag.DistrictDesc = siteUser.Districts[0].Name; int schoolYearId = modelService.GetSchoolYearId(Convert.ToInt32(hiddenSchoolYearFilter)); ViewBag.SchoolId = modelService.DropDownDataSchool(hiddenSchoolFilter, siteUser.EdsUserId, schoolYearId, true); ViewBag.AllowEdit = HelperService.AllowUiEdits(siteUser.RoleDesc, "STUDENT"); ViewBag.SchoolYearList = schoolService.DropDownDataSchoolYear(hiddenSchoolYearFilter); ViewBag.SchoolYear = hiddenSchoolYearFilter; return View("Index", new SiteModels() { Students = studentService.GetViewData(hiddenSchoolYearFilter, hiddenSchoolFilter) }); } catch (Exception ex) { Logging log = new Logging(); log.LogException(ex); return View("GeneralError"); } }
// GET: /Students/ public ActionResult Index() { try { dbTIREntities db = new dbTIREntities(); SiteUser siteUser = ((SiteUser)Session["SiteUser"]); StudentService studentService = new StudentService(siteUser, db); SchoolService schoolService = new SchoolService(siteUser, db); ModelServices modelService = new ModelServices(); string currentSchoolYear = schoolService.GetCurrentSchoolYear(); ViewBag.DistrictDesc = siteUser.Districts[0].Name; int schoolYearId = modelService.SchoolYearId(); ViewBag.SchoolId = modelService.DropDownDataSchool("", siteUser.EdsUserId, schoolYearId, true); ViewBag.AllowEdit = HelperService.AllowUiEdits(siteUser.RoleDesc, "STUDENT"); //ViewBag.SchoolYear = HelperService.SchoolYearDescription(db); ViewBag.SchoolYearList = schoolService.DropDownDataSchoolYear(currentSchoolYear); ViewBag.AllowEdit = HelperService.AllowUiEdits(siteUser.RoleDesc, "STUDENT"); ViewBag.SchoolYear = currentSchoolYear; return View(new SiteModels() { Students = studentService.GetViewData(currentSchoolYear, "", "") }); } catch (Exception ex) { Logging log = new Logging(); log.LogException(ex); return View("GeneralError"); } }
public ActionResult GetSchoolByYear(string schoolYear) { ModelServices modelService = new ModelServices(); SiteUser siteUser = ((SiteUser)Session["SiteUser"]); int schoolYearId = modelService.GetSchoolYearId(Convert.ToInt32(schoolYear)); return Json(modelService.DropDownDataSchool("", siteUser.EdsUserId, schoolYearId, true), JsonRequestBehavior.AllowGet); }
public ActionResult Search(string searchClass, string hiddenSchoolFilterSearch, string hiddenSchoolYearFilterSearch) { try { dbTIREntities db = new dbTIREntities(); SiteUser siteUser = ((SiteUser)Session["SiteUser"]); ClassService classService = new ClassService(siteUser, db); SchoolService schoolService = new SchoolService(siteUser, db); ModelServices modelService = new ModelServices(); ViewBag.DistrictDesc = siteUser.Districts[0].Name; int schoolYearId = modelService.GetSchoolYearId(Convert.ToInt32(hiddenSchoolYearFilterSearch)); ViewBag.SchoolId = modelService.DropDownDataSchool(hiddenSchoolFilterSearch, siteUser.EdsUserId, schoolYearId, true); ViewBag.SchoolYear = schoolService.DropDownDataSchoolYear(hiddenSchoolYearFilterSearch); ViewBag.AllowEdit = HelperService.AllowUiEdits(siteUser.RoleDesc, "CLASS"); return View("Index", new SiteModels() { SchoolClasses = classService.GetViewData(hiddenSchoolYearFilterSearch, hiddenSchoolFilterSearch, searchClass) }); } catch (Exception ex) { Logging log = new Logging(); log.LogException(ex); return View("GeneralError"); } }
private void PopulateViewData(tblClass tblclass, ClassWizardSteps? defaultWizardStep, bool? showTeachersForDistrict, bool? showStudentsForDistrict) { ViewBag.DefaultWizardStep = defaultWizardStep; ViewBag.ShowTeachersForDistrict = !showTeachersForDistrict.GetValueOrDefault(); ViewBag.ShowStudentsForDistrict = !showStudentsForDistrict.GetValueOrDefault(); var db = new dbTIREntities(); SiteUser siteUser = (SiteUser)Session["SiteUser"]; SchoolService schoolService = new SchoolService(siteUser, db); ClassService classService = new ClassService(siteUser, db); ModelServices modelService = new ModelServices(); int userAssignedDistrict = siteUser.Districts[0].Id; bool filterTeachersByDistrict = showTeachersForDistrict.GetValueOrDefault(); int districtId = userAssignedDistrict; // Get teachers for this class var teachersForThisClass = classService.GetTeachersForThisClass(tblclass); // Get teachers not in this class var teachersNotForThisClass = classService.GetTeachersNotForThisClass(tblclass, filterTeachersByDistrict, districtId); //Get students for this class var studentsForThisClass = classService.GetStudentForThisClass(tblclass); // Get students not for this class var availableStudents = classService.GetStudentNotForThisClass(tblclass, districtId); var availableStudentsForSchool = classService.GetStudentForSchool(tblclass, districtId); // Add data to ViewBag for form ViewBag.TeachersForThisClass = new MultiSelectList(teachersForThisClass, "TeacherId", "FullName", null); ViewBag.AvailableTeachers = new MultiSelectList(teachersNotForThisClass, "TeacherId", "FullName", null); if (showStudentsForDistrict.GetValueOrDefault()) { ViewBag.AvailableStudents = new MultiSelectList(availableStudents, "StudentId", "FullName", null); } else { ViewBag.AvailableStudents = new MultiSelectList(availableStudentsForSchool, "StudentId", "FullName", null); } ViewBag.StudentsForThisClass = new MultiSelectList(studentsForThisClass, "StudentId", "FullName", null); ViewBag.StudentsForThisClassCount = studentsForThisClass.Count(); ViewBag.SchoolId = modelService.DropDownDataSchool(Convert.ToString(tblclass.SchoolId), siteUser.EdsUserId, tblclass.SchoolYearId, false); ViewBag.SchoolYearId = modelService.GetUserSchoolYear(siteUser.EdsUserId, siteUser.Districts[0].Id, tblclass.SchoolYearId); ViewBag.ClassDesc = db.tblClasses.Where(x => x.ClassId == tblclass.ClassId).Select(x => x.ClassDesc).SingleOrDefault(); ViewBag.SubjectId = new SelectList(db.tblSubjects.OrderBy(x => x.SubjectDesc), "SubjectId", "SubjectDesc", tblclass.SubjectId); ViewBag.AllowEdit = HelperService.AllowUiEdits(siteUser.RoleDesc, "CLASS"); }
public ActionResult Create([Bind(Include = "ClassId,SchoolId,ClassDesc,SchoolYearId,SubjectId,Grade,CreateDatetime,ChangeDatetime")] tblClass tblclass) { try { var db = new dbTIREntities(); SiteUser su = (SiteUser)Session["SiteUser"]; SchoolService schoolService = new SchoolService(su, db); ModelServices modelService = new ModelServices(); if (ModelState.IsValid) { ClassService classService = new ClassService((SiteUser)Session["SiteUser"], db); if (!(classService.IsClassExists(tblclass))) { classService.AddClass(newClass: tblclass); return RedirectToAction("Edit", new { id = tblclass.ClassId, defaultWizardStep = ClassWizardSteps.Teachers }); } else { int defaultDistrict = su.Districts[0].Id; ViewBag.DistrictDesc = su.Districts[0].Name; ModelState.AddModelError("ClassDesc", "Duplicate class name - please choose a unique name."); } } ViewBag.SchoolId = modelService.DropDownDataSchool("", su.EdsUserId, tblclass.SchoolYearId, false); ViewBag.SchoolYearId = modelService.GetUserSchoolYear(su.EdsUserId, su.Districts[0].Id, tblclass.SchoolYearId); ViewBag.SubjectId = new SelectList(db.tblSubjects.OrderBy(x => x.SubjectDesc), "SubjectId", "SubjectDesc", tblclass.SubjectId); return View(tblclass); } catch (Exception ex) { Logging log = new Logging(); log.LogException(ex); return View("GeneralError"); } }
// GET: /Classes/Create public ActionResult Create() { try { SiteUser siteUser = (SiteUser)Session["SiteUser"]; var db = new dbTIREntities(); SchoolService schoolService = new SchoolService(siteUser, db); ModelServices modelService = new ModelServices(); int defaultDistrict = siteUser.Districts[0].Id; ViewBag.DistrictDesc = siteUser.Districts[0].Name; int schoolYearId = modelService.SchoolYearId(); ViewBag.SchoolId = modelService.DropDownDataSchool("", siteUser.EdsUserId, schoolYearId, false); ViewBag.SchoolYearId = modelService.GetUserSchoolYear(siteUser.EdsUserId, defaultDistrict, schoolYearId); ViewBag.SubjectId = new SelectList(db.tblSubjects.OrderBy(x => x.SubjectDesc), "SubjectId", "SubjectDesc"); return View(); } catch (Exception ex) { Logging log = new Logging(); log.LogException(ex); return View("GeneralError"); } }
public ActionResult Edit([Bind(Include = "ClassId,SchoolId,ClassDesc,SchoolYearId,SubjectId,Grade")] tblClass tblclass) { try { var db = new dbTIREntities(); SiteUser siteUser = (SiteUser)Session["SiteUser"]; SchoolService schoolService = new SchoolService(siteUser, db); ModelServices modelService = new ModelServices(); if (ModelState.IsValid) { ClassService classService = new ClassService((SiteUser)Session["SiteUser"], db); if (!(classService.IsEditClassExists(tblclass))) { classService.EditClass(editClass: tblclass); return RedirectToAction("Edit", new { id = tblclass.ClassId, defaultWizardStep = ClassWizardSteps.Teachers }); } else { PopulateViewData(tblclass, null, null, null); ModelState.AddModelError("ClassDesc", "Duplicate class name - please choose a unique name."); return View(tblclass); } } ViewBag.SchoolYearId = modelService.GetUserSchoolYear(siteUser.EdsUserId, siteUser.Districts[0].Id, tblclass.SchoolYearId); ViewBag.SchoolId = modelService.DropDownDataSchool(tblclass.SchoolId.ToString(), siteUser.EdsUserId, tblclass.SchoolYearId, true); ViewBag.SubjectId = new SelectList(db.tblSubjects, "SubjectId", "SubjectDesc", tblclass.SubjectId); return View(tblclass); } catch (Exception ex) { Logging log = new Logging(); log.LogException(ex); return View("GeneralError"); } }