public ActionResult CreateKnowledgeBaseItem() { SiteUser siteUser = (SiteUser)Session["SiteUser"]; ModelServices modelService = new ModelServices(); ViewBag.RoleId = new SelectList(modelService.GetRolesForRole((int)(siteUser.Role)), "RoleId", "RoleDesc"); return View(); }
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"); } }
public TeachersController() { _db = new dbTIREntities(); _modelServices = new ModelServices(); ViewBag.SchoolYear = _modelServices.SchoolYearDescription(); }
// 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 UpdateGrid(int hiddenYearFilter) { try { SiteUser su = ((SiteUser)Session["SiteUser"]); ModelServices modelServices = new ModelServices(); WeightingModel data = new WeightingModel(); int userAssignedDistrict = su.Districts[0].Id; data.DistrictName = modelServices.GetDistrictName(userAssignedDistrict); data.SchoolYear = modelServices.SchoolYearDescriptionByYearId(hiddenYearFilter); data.DropDown = new DropDownData(); data.DropDown.Year = new YearDropDown(modelServices.SchoolYearDropDownData()); data.DropDown.Year.SelectedYear = hiddenYearFilter; data.SummaryList = modelServices.GetWeightingSummary(userAssignedDistrict, hiddenYearFilter); ; return View("Index", data); } catch (Exception ex) { Logging log = new Logging(); log.LogException(ex); return View("GeneralError"); } }
public ActionResult Index(int studentId, string cameFromTitle, bool showRawScale = false, int summaryCount = 0, int detailCount = 0) { try { base.SetNavigationLinksUrl(); ModelServices modelServices = new ModelServices(); StudentHistoryModel data = new StudentHistoryModel(); ViewBag.StudentId = studentId; ViewBag.ShowRawScale = showRawScale; ViewBag.Count = detailCount + 1; ViewBag.SummaryCount = summaryCount + 1; SiteUser su = ((SiteUser)Session["SiteUser"]); data.History = modelServices.GetStudentHistoryReport(studentId, showRawScale, su.Districts.First().Id); tblStudent tempStudent = modelServices.GetStudentById(studentId); data.CameFromTitle = cameFromTitle; data.Student = tempStudent.FirstName + " " + tempStudent.LastName; data.District = modelServices.GetDistrictName(int.Parse(tempStudent.DistrictId.ToString())); data.School = modelServices.GetSchoolNameByStudentId(studentId); return View("Index", data); } catch (Exception ex) { Logging log = new Logging(); log.LogException(ex); return View("GeneralError"); } }
// // GET: /AssessmentClassScore/ public ActionResult Index() { AssessmentClassScoreViewModel model = new AssessmentClassScoreViewModel(); modelServices = new ModelServices(); int schoolYearId = modelServices.SchoolYearId(); model.SchoolYearId = Convert.ToString(schoolYearId); FillDropDowns(model, false); return View(model); }
public ActionResult CreateKnowledgeBaseItem(KnowledgeBase model) { try { SiteUser siteUser = (SiteUser)Session["SiteUser"]; ModelServices modelService = new ModelServices(); List<HttpPostedFileBase> httpPostedFileBases = null; if (model.Files.ToList()[0] != null) { httpPostedFileBases = model.Files.ToList(); var allowedFileSize = ConfigurationManager.AppSettings["FileSize"].ToString(); if (!DocumentManagementService.ValidateAttachmentSize(httpPostedFileBases)) { ModelState.AddModelError("Files", "Attachment Size exceeds allowed limit of " + allowedFileSize + " MB"); } } if (ModelState.IsValid) { var db = new dbTIREntities(); KnowledgeBaseService kbService = new KnowledgeBaseService(siteUser, db); if (!kbService.IsKnowledgeBaseExists(model.Title)) { //TODO: Till nowwe are picking first district Id. Need to refactor code when a user belongs to more than 1 district. model.DistrictId = siteUser.Districts[0].Id; model.RoleId = model.RoleId; model.CreatedDateTime = DateTime.Now; model.CreatedUserId = siteUser.EdsUserId; model.FileDetails = model.Files.ToList()[0] != null ? DocumentManagementService.GetFileDetail(model.Files) : null; kbService.SaveKnowledgeBase(model); return RedirectToAction("Index"); } else { ModelState.AddModelError("Title", "Duplicate Title - please choose a unique title."); } } ViewBag.RoleId = new SelectList(modelService.GetRolesForRole((int)(siteUser.Role)), "RoleId", "RoleDesc"); return View(); } catch (Exception ex) { Logging log = new Logging(); log.LogException(ex); return View("GeneralError"); } }
public static ReportFilterViewModel PopulateReportFilterViewModel(FilterParameter filterParameter, ModelServices modelService, SiteUser siteUser) { string defaultText = "All"; var reportFilterViewModel = new ReportFilterViewModel(); reportFilterViewModel.TeacherName = modelService.GetUserNameByUserId(filterParameter.Teacher); reportFilterViewModel.ClassName = filterParameter.ClassId != -1 ? modelService.GetClassDesc(filterParameter.ClassId) : defaultText; reportFilterViewModel.Race = (filterParameter.Race == -1) ? defaultText : modelService.GetRaceDesc(filterParameter.Race); reportFilterViewModel.Gender = (filterParameter.Gender == -1) ? defaultText : modelService.GetGenderDesc(filterParameter.Gender); //TODO: till now first record with district name and Id is picked up. Need to refactor if user belongs to multiple district. reportFilterViewModel.DistrictName = siteUser.Districts.First().Name; reportFilterViewModel.IsAdmin = HelperService.AllowUiEdits(siteUser.RoleDesc, "REPORT"); reportFilterViewModel.DisplayAdminFilters = DecideFilterDisplay(filterParameter); reportFilterViewModel.FrlIndicator = filterParameter.FrlIndicator; reportFilterViewModel.LepIndicator = filterParameter.LEPIndicator; reportFilterViewModel.IepIndicator = filterParameter.IEPIndicator; reportFilterViewModel.Hispanic = filterParameter.Hispanic; reportFilterViewModel.SchoolYear = filterParameter.SchoolYear; return reportFilterViewModel; }
public ActionResult UpdateGrid(string hiddenSchoolFilter, string schoolYearFilter) { try { db = new dbTIREntities(); siteUser = ((SiteUser)Session["SiteUser"]); userService = new UserService(siteUser, db); schoolService = new SchoolService(siteUser, db); modelService = new ModelServices(); ViewBag.SchoolYearList = schoolService.DropDownDataSchoolYear(schoolYearFilter); int schoolYearId = modelService.GetSchoolYearId(Convert.ToInt32(schoolYearFilter)); FillViewBagValues(siteUser.Districts[0].Name, hiddenSchoolFilter, siteUser.RoleDesc, schoolYearId); return View("Index", userService.GetViewData(schoolYearFilter, hiddenSchoolFilter, "")); } catch (Exception ex) { Logging log = new Logging(); log.LogException(ex); return View("GeneralError"); } }
public ActionResult Index() { try { db = new dbTIREntities(); siteUser = ((SiteUser)Session["SiteUser"]); userService = new UserService(siteUser, db); schoolService = new SchoolService(siteUser, db); modelService = new ModelServices(); int schoolYearId = modelService.SchoolYearId(); string currentSchoolYear = schoolService.GetCurrentSchoolYear(); ViewBag.SchoolYearList = schoolService.DropDownDataSchoolYear(currentSchoolYear); FillViewBagValues(siteUser.Districts[0].Name, string.Empty, siteUser.RoleDesc, schoolYearId); return View(userService.GetViewData(currentSchoolYear, "", "")); } catch (Exception ex) { Logging log = new Logging(); log.LogException(ex); return View("GeneralError"); //throw; } }
public ActionResult SummaryReportById(int teacherId, bool viewMeetExceedSummary = true) { try { SetNavigationLinksUrl(); SetViewBag(viewMeetExceedSummary); ViewBag.SummaryLink = "SummaryReportById"; ViewBag.TeacherFilter = teacherId; bool unAuthorizedRequest = false; SiteUser su = ((SiteUser)Session["SiteUser"]); ModelServices modelServices = new ModelServices(); StudentService studentService = new StudentService(su, entities); int defaultDistrict = su.Districts[0].Id; int schoolYearId = modelServices.SchoolYearId(); int[] userSchools = modelServices.getSchoolsByUserId(su.EdsUserId).ToArray(); var dropdownTeachers = modelServices.TeacherDropDownDataBySchoolAndYear(userSchools, schoolYearId, defaultDistrict); unAuthorizedRequest = dropdownTeachers.Where(x => x.Id == teacherId).Count() == 0 ? true : false; if (unAuthorizedRequest) { return RedirectToAction("AccessDenied", "Error"); } TIRSummaryModel data = new TIRSummaryModel(); data.SchoolYear = modelServices.SchoolYearDescription(); data.DropDown = new DropDownData(); data.DropDown.Year = new YearDropDown(modelServices.SchoolYearDropDownData()); data.DropDown.Year.SelectedYear = schoolYearId; data.DropDown.District = new DistrictDropDown(modelServices.DistrictDropDownDataByUser(su.EdsUserId)); data.DropDown.Teacher = new TeacherDropDown(dropdownTeachers); data.DropDown.Teacher.SelectedTeacher = teacherId; data.DropDown.Race = new RaceDropDown(modelServices.DropDownDataForRace(), true); data.DropDown.Gender = new GenderDropDown(modelServices.DropDownDataForGender(), true); data.DropDown.SchoolClass = new ClassDropDown(modelServices.GetClassesByTeacher(schoolYearId, new[] { teacherId })); var filterParameter = new FilterParameter { ClassId = classDefaultValue, Teacher = teacherId, School = userSchools.First(), Year = schoolYearId, SchoolYear = data.SchoolYear }; data.SummaryList = modelServices.GetSummaryReport(filterParameter); data.DropDown.School = new SchoolDropDown(modelServices.GetSchoolDropDownData(su.EdsUserId, schoolYearId)); var reportFilterViewModel = ReportsFilterHelper.PopulateReportFilterViewModel(filterParameter, modelServices, su); ViewBag.ReportFilters = reportFilterViewModel; return View("SummaryReport", data); } catch (Exception ex) { Logging log = new Logging(); log.LogException(ex); return View("GeneralError"); } }
private void FillUserExtendedCommanData(ModelServices modelService, tblUserExt tbluserExtended) { ViewBag.RoleId = new SelectList(modelService.GetRolesForRole((int)(siteUser.Role)), "RoleId", "RoleDesc", tbluserExtended.RoleId); ViewBag.SchoolYear = schoolService.GetSchoolYearDownData((int)tbluserExtended.SchoolYearId); int currentSchoolYear = Convert.ToInt32(schoolService.GetCurrentSchoolYear()); ViewBag.CurrentSchoolYearId = modelService.GetSchoolYearId(currentSchoolYear); var classData = modelService.GetClassesByTeacher((int)tbluserExtended.SchoolYearId, new[] { (int)tbluserExtended.UserId }); tbluserExtended.SchoolClasses = new List<SchoolClass>(); foreach (var classItem in classData) { SchoolClass classItems = new SchoolClass() { ClassDesc = classItem.Name, SchoolClassId = classItem.Id }; tbluserExtended.SchoolClasses.Add(classItems); } }
public ActionResult Edit(tblUserExt tblUserExtended) { try { db = new dbTIREntities(); modelService = new ModelServices(); siteUser = ((SiteUser)Session["SiteUser"]); userService = new UserService(siteUser, db); schoolService = new SchoolService(siteUser, db); int userAssignedDistrict = siteUser.Districts[0].Id; if (ModelState.IsValid) { if (tblUserExtended.SelectedSchools != null && tblUserExtended.SelectedSchools.Count() > 0) { bool isEmailAddressExist = db.tblUsers.Where(x => x.UserEmail == tblUserExtended.UserEmail && x.UserId != tblUserExtended.UserId).Count() > 0 ? true : false; bool isStateIdExist = db.tblUsers.Where(x => x.StateId == tblUserExtended.StateId && x.UserId != tblUserExtended.UserId).Count() > 0 ? true : false; if ((!isEmailAddressExist) && (!isStateIdExist)) { userService.UpdateUser(tblUserExtended); HelperService.UpdateSiteUserProfile(siteUser, db); return RedirectToAction("Index"); } else { if (isEmailAddressExist) ModelState.AddModelError("UserEmail", "Duplicate email - please choose a unique email."); if (isStateIdExist) ModelState.AddModelError("StateId", "Duplicate state id - please choose a unique state."); } } else { ViewBag.SchoolMessage = "Required"; } } tblUserExtended.Schools = userService.GetSelectedSchoolCheckBoxes(tblUserExtended); FillViewBagValues(siteUser.Districts[0].Name, string.Empty, siteUser.RoleDesc, tblUserExtended.SchoolYearId); FillUserExtendedCommanData(modelService, tblUserExtended); return View(tblUserExtended); } catch (Exception ex) { Logging log = new Logging(); log.LogException(ex); return View("GeneralError"); } }
public async Task<ActionResult> Create(tblUserExt tblUserExtended) { try { db = new dbTIREntities(); modelService = new ModelServices(); siteUser = ((SiteUser)Session["SiteUser"]); userService = new UserService(siteUser, db); schoolService = new SchoolService(siteUser, db); int userAssignedDistrict = siteUser.Districts[0].Id; string currentSchoolYear = schoolService.GetCurrentSchoolYear(); if (ModelState.IsValid) { if (tblUserExtended.SelectedSchools != null && tblUserExtended.SelectedSchools.Count() > 0) { var context = new Models.ApplicationDbContext(); var userManager = new UserManager<ApplicationUser>(new UserStore<ApplicationUser>(context)); // 1. Create ASPNET user string userName = tblUserExtended.UserName; string password = tblUserExtended.Password; var isPasswordValid = password != null && password.Length >= 6 ? true : false; var isUserNameExist = userManager.FindByName(userName); bool isEmailAddressExist = db.tblUsers.Where(x => x.UserEmail == tblUserExtended.UserEmail).Count() > 0 ? true : false; bool isStateIdExist = db.tblUsers.Where(x => x.StateId == tblUserExtended.StateId).Count() > 0 ? true : false; if ((isUserNameExist == null) && (!isEmailAddressExist) && (!isStateIdExist) && (isPasswordValid)) { var user = new ApplicationUser() { UserName = userName }; var result = await userManager.CreateAsync(user, password); if (result.Succeeded) { // 2. Create EDS user ApplicationUser newAspNetUser = userManager.FindByName(userName); if (newAspNetUser != null) { userService.CreateEdsUser(newAspNetUser.Id, tblUserExtended); } } else { throw new Exception(String.Format("ERROR: {0}", result.Errors)); } return RedirectToAction("Index"); } else { if (isUserNameExist != null) ModelState.AddModelError("UserName", "Duplicate name - please choose a unique name."); if (isEmailAddressExist) ModelState.AddModelError("UserEmail", "Duplicate email - please choose a unique email."); if (isStateIdExist) ModelState.AddModelError("StateId", "Duplicate state id - please choose a unique state."); if (!isPasswordValid) ModelState.AddModelError("Password", "Please enter password at least 6 characters."); } } else { ViewBag.SchoolMessage = "Required"; } } tblUserExtended.Schools = userService.GetSelectedSchoolCheckBoxes(tblUserExtended); ViewBag.RoleId = new SelectList(modelService.GetRolesForRole((int)(siteUser.Role)), "RoleId", "RoleDesc", tblUserExtended.RoleId); FillViewBagValues(siteUser.Districts[0].Name, string.Empty, siteUser.RoleDesc, tblUserExtended.SchoolYearId); return View(tblUserExtended); } catch (Exception ex) { Logging log = new Logging(); log.LogException(ex); return View("GeneralError"); } }
public ActionResult Edit(int? id, int schoolYearId) { try { db = new dbTIREntities(); modelService = new ModelServices(); siteUser = ((SiteUser)Session["SiteUser"]); schoolService = new SchoolService(siteUser, db); userService = new UserService(siteUser, db); //tblUserExt tbluserExtended = null; if (id == null) { return new HttpStatusCodeResult(HttpStatusCode.BadRequest); } tblUser tbluser = db.tblUsers.Find(id); if (tbluser == null) { return new HttpStatusCodeResult(HttpStatusCode.BadRequest); } var context = new Models.ApplicationDbContext(); var userManager = new UserManager<ApplicationUser>(new UserStore<ApplicationUser>(context)); string aspNetUserName = "******"; if (!String.IsNullOrEmpty(tbluser.AspNetUserId)) { ApplicationUser aspNetUser = userManager.FindById(tbluser.AspNetUserId); if (aspNetUser != null) { aspNetUserName = aspNetUser.UserName; } } //Get RoleId from tblUserDistrict instead of tblUser int roleId = userService.GetRoleId(id, schoolYearId); tblUserExt tbluserExtended = new tblUserExt() { UserId = tbluser.UserId, UserName = aspNetUserName, FirstName = tbluser.FirstName, LastName = tbluser.LastName, UserEmail = tbluser.UserEmail, StateId = tbluser.StateId, Schools = tbluser.Schools, SchoolYearId = schoolYearId, RoleId = roleId }; //Check that edited user's school must be from EDSUser schools or edsUser must have permissions to view user school bool isUserHasPermissionForSchool = userService.IsUserHasPermissionForSchool(tbluserExtended); if (!isUserHasPermissionForSchool) { return RedirectToAction("Index"); } //Get User schools tbluserExtended.Schools = userService.GetUserSchoolWithCheckBoxes(tbluserExtended); var dropDownEmpty = Enumerable.Repeat(new SelectListItem { Value = "", Text = "" }, count: 1); FillViewBagValues(siteUser.Districts[0].Name, string.Empty, siteUser.RoleDesc, schoolYearId); FillUserExtendedCommanData(modelService, tbluserExtended); return View(tbluserExtended); } catch (Exception ex) { Logging log = new Logging(); log.LogException(ex); return View("GeneralError"); } }
public ActionResult Create(int schoolYear) { try { dbTIREntities db = new dbTIREntities(); StudentExt studentExt = new StudentExt(); ModelServices modelService = new ModelServices(); studentExt.SchoolYear = schoolYear; PopulateViewData(studentExt); studentExt.SchoolYearDesc = HelperService.SchoolYearDescription(db); studentExt.SchoolYearId = modelService.SchoolYearId(); return View(studentExt); } catch (Exception ex) { Logging log = new Logging(); log.LogException(ex); return View("GeneralError"); } }
// GET: /User/Create public ActionResult Create() { try { db = new dbTIREntities(); siteUser = ((SiteUser)Session["SiteUser"]); modelService = new ModelServices(); schoolService = new SchoolService(siteUser, db); userService = new UserService(siteUser, db); int userAssignedDistrict = siteUser.Districts[0].Id; int schoolYearId = modelService.SchoolYearId(); tblUserExt userExtended = new tblUserExt(); userExtended.SchoolYearId = schoolYearId; userExtended.Schools = userService.GetSchoolWithCheckBoxes(userExtended); ViewBag.RoleId = new SelectList(modelService.GetRolesForRole((int)(siteUser.Role)), "RoleId", "RoleDesc"); FillViewBagValues(siteUser.Districts[0].Name, string.Empty, siteUser.RoleDesc, schoolYearId); return View(userExtended); } catch (Exception ex) { Logging log = new Logging(); log.LogException(ex); return View("GeneralError"); } }
public ActionResult SummaryReport(bool viewMeetExceedSummary = true) { try { SetNavigationLinksUrl(); ViewBag.SummaryLink = "SummaryReport"; SetViewBag(viewMeetExceedSummary); SiteUser su = ((SiteUser)Session["SiteUser"]); ModelServices modelServices = new ModelServices(); StudentService studentService = new StudentService(su, entities); int defaultDistrict = su.Districts[0].Id; int schoolYearId = modelServices.SchoolYearId(); int[] userSchools = modelServices.getSchoolsByUserId(su.EdsUserId).ToArray(); TIRSummaryModel data = new TIRSummaryModel(); data.SchoolYear = modelServices.SchoolYearDescription(); data.DropDown = new DropDownData(); data.DropDown.Year = new YearDropDown(modelServices.SchoolYearDropDownData()); data.DropDown.Year.SelectedYear = schoolYearId; data.DropDown.District = new DistrictDropDown(modelServices.DistrictDropDownDataByUser(su.EdsUserId)); data.DropDown.Race = new RaceDropDown(modelServices.DropDownDataForRace(), true); data.DropDown.Race.SelectedRace = -1; data.DropDown.Gender = new GenderDropDown(modelServices.DropDownDataForGender(), true); data.DropDown.Gender.SelectedGender = -1; data.DropDown.School = new SchoolDropDown(modelServices.GetSchoolDropDownData(su.EdsUserId, schoolYearId)); if (su.isTeacher) { data.DropDown.Teacher = new TeacherDropDown( new List<DropDownIdName>() { new DropDownIdName() { Id = su.EdsUserId, Name = su.UserFullName } }); data.DropDown.SchoolClass = new ClassDropDown(modelServices.GetClassesByTeacher(schoolYearId, new[] { su.EdsUserId })); } else // data administrator and eds administrator { int[] schoolsTeacher = modelServices.getTeachersBySchoolsId(userSchools).ToArray(); data.DropDown.Teacher = new TeacherDropDown(modelServices.TeacherDropDownDataBySchoolAndYear(userSchools, schoolYearId, defaultDistrict)); data.DropDown.SchoolClass = new ClassDropDown(modelServices.GetClassesByTeacher(schoolYearId, schoolsTeacher)); } var filterParameter = new FilterParameter { ClassId = classDefaultValue, Teacher = su.EdsUserId, School = userSchools.First(), Year = schoolYearId, SchoolYear = data.SchoolYear }; data.SummaryList = modelServices.GetSummaryReport(filterParameter); var reportFilterViewModel = ReportsFilterHelper.PopulateReportFilterViewModel(filterParameter, modelServices, su); ViewBag.ReportFilters = reportFilterViewModel; return View(data); } catch (Exception ex) { Logging log = new Logging(); log.LogException(ex); return View("GeneralError"); } }
private void FillDropDowns(AssessmentClassScoreViewModel model, bool isPostBack) { siteUser = ((SiteUser)Session["SiteUser"]); db = new dbTIREntities(); commonService = new CommonService(siteUser, db); modelServices = new ModelServices(); model.DropDown = new DropDownData(); int schoolYearId = int.Parse(model.SchoolYearId); model.DistrictName = siteUser.Districts[0].Name; model.DistrictId = siteUser.Districts[0].Id; model.Assessment = commonService.GetAssessmentType(); model.SchoolYears = commonService.GetSchoolYear(); model.SchoolTerms = commonService.GetSchoolTerm(); model.Subjects = commonService.GetSubjects(); int[] userSchools = modelServices.getSchoolsByUserId(siteUser.EdsUserId).ToArray(); model.DropDown.School = new SchoolDropDown(modelServices.GetSchoolDropDownData(siteUser.EdsUserId, schoolYearId), true, "--SELECT--", ""); int[] schoolsTeacher = modelServices.getTeachersBySchoolsId(userSchools).ToArray(); if (isPostBack) { model.DropDown.Teacher = new TeacherDropDown(modelServices.TeacherDropDownDataBySchoolAndYear(new int[] { int.Parse(model.SchoolId) }, schoolYearId, model.DistrictId), "--SELECT--", ""); model.DropDown.SchoolClass = new ClassDropDown(modelServices.GetClassesByTeacher(schoolYearId, new[] { int.Parse(model.TeacherId) }), "--SELECT--", ""); } else { model.DropDown.Teacher = new TeacherDropDown(modelServices.TeacherDropDownDataBySchoolAndYear(userSchools, schoolYearId, model.DistrictId), "--SELECT--", ""); model.DropDown.SchoolClass = new ClassDropDown(modelServices.GetClassesByTeacher(schoolYearId, schoolsTeacher), "--SELECT--", ""); } }
public ActionResult ResetPassword(ResetPasswordModel model) { try { ModelServices services = new ModelServices(); string email = services.GetEmailByUserId(model.UserName); if (email != string.Empty && email != null) { string token = services.GeneratePasswordResetToken(model.UserName, email); if (ConfigurationManager.AppSettings["systemMode"].ToString() == "debug") { services.EmailPasswordReset(@"*****@*****.**", token, services.GetUserIdByUserName(model.UserName)); } else { services.EmailPasswordReset(email, token, services.GetUserIdByUserName(model.UserName)); } return RedirectToAction("ResetPwStepTwo"); } else { ModelState.AddModelError("UserName", "Username not found"); return View(); } } catch (Exception ex) { Logging log = new Logging(); log.LogException(ex); return View("GeneralError"); } //return RedirectToAction("InvalidUserName"); }
public ActionResult ResetPasswordConfirmation(string token, string id) { //if (WebSecurity.ResetPassword(model.Token, model.NewPassword)) //{ // return RedirectToAction("PasswordResetSuccess"); //} ModelServices modelServices = new ModelServices(); try { if (modelServices.IsResetTokenValid(token, id)) { ResetPasswordConfirmModel data = new ResetPasswordConfirmModel() { Token = token }; return View(data); } } catch (Exception ex) { Logging log = new Logging(); log.LogException(ex); return View("GeneralError"); } return RedirectToAction("PasswordResetFailure"); }
public void PopulateViewData(StudentExt studentExt) { dbTIREntities db = new dbTIREntities(); SiteUser siteUser = ((SiteUser)Session["SiteUser"]); StudentService studentService = new StudentService(siteUser, db); ModelServices modelService = new ModelServices(); studentExt.DistrictId = siteUser.Districts[0].Id; studentExt.DistrictDesc = siteUser.Districts[0].Name; studentExt.StudentClasses = studentExt.StudentId != 0 ? modelService.GetClassesByStudent(studentExt.StudentId, studentExt.SchoolYear) : null; studentExt.SchoolYears = studentExt.StudentId != 0 ? modelService.GetSchoolYearByStudent(studentExt.StudentId) : null; studentExt.DropDown = new DropDownData(); int schoolYearId = modelService.GetSchoolYearId(studentExt.SchoolYear); studentExt.DropDown.School = new SchoolDropDown(modelService.GetSchoolDropDownData(siteUser.EdsUserId, schoolYearId), false); studentExt.DropDown.School.SelectedSchool = studentExt.ServingSchoolId; studentExt.DropDown.Grade = new GradeDropDown(studentService.DropDownDataForGrade()); studentExt.DropDown.Grade.SelectedGrade = (studentExt.GradeLevel != null) ? (int)studentExt.GradeLevel : -1; studentExt.DropDown.Gender = new GenderDropDown(modelService.DropDownDataForGender()); studentExt.DropDown.Gender.SelectedGender = (studentExt.GenderId != null) ? (int)studentExt.GenderId : 1; studentExt.DropDown.Lineage = new LineageDropDown(studentService.DropDownDataForLineage()); studentExt.DropDown.Lineage.SelectedLineage = (studentExt.LineageId != null) ? (int)studentExt.LineageId : -1; studentExt.DropDown.HomeLanguage = new LanguageDropDown(studentService.DropDownDataForLanguage()); studentExt.DropDown.HomeLanguage.SelectedLanguage = (studentExt.HomeLanguageId != null) ? (int)studentExt.HomeLanguageId : -1; studentExt.DropDown.NativeLanguage = new LanguageDropDown(studentService.DropDownDataForLanguage()); studentExt.DropDown.NativeLanguage.SelectedLanguage = (studentExt.NativeLanguageId != null) ? (int)studentExt.NativeLanguageId : -1; studentExt.DropDown.Race = new RaceDropDown(modelService.DropDownDataForRace()); studentExt.DropDown.Race.SelectedRace = (studentExt.RaceId != null) ? (int)studentExt.RaceId : -1; ViewBag.SchoolYear = studentExt.SchoolYear; }
public ActionResult ResetPasswordConfirmation(ResetPasswordConfirmModel model) { ModelServices modelServices = new ModelServices(); try { string aspId = modelServices.GetAspUserIdForToken(model.Token); UserManager.RemovePassword(aspId); UserManager.AddPassword(aspId, model.NewPassword); } catch (Exception ex) { Logging log = new Logging(); log.LogException(ex); return View("GeneralError"); } return RedirectToAction("PasswordResetComplete"); }
public ActionResult Edit(int studentId, int schoolYear) { try { dbTIREntities db = new dbTIREntities(); SiteUser siteUser = ((SiteUser)Session["SiteUser"]); StudentService studentService = new StudentService(siteUser, db); ModelServices modelService = new ModelServices(); StudentExt studentExt = studentService.GetStudentDetail(studentId, schoolYear); PopulateViewData(studentExt); ViewBag.AllowEdit = HelperService.AllowUiEdits(siteUser.RoleDesc, "STUDENT"); return View(studentExt); } catch (Exception ex) { Logging log = new Logging(); log.LogException(ex); return View("GeneralError"); } }
private void UpdateReportTemplateConfigurations(ModelServices modelService, int reportTemplateId) { var reportTemplateConfigs = modelService.GetReportTemplateConfigurations(reportTemplateId); ViewBag.Projection = reportTemplateConfigs["ProjectionTitle"].Trim(); }
public JsonServiceController() { _modelServices = new ModelServices(); }
private void InitializeAssessmentScoreMetadata(AssessmentClassScoreViewModel model) { int decimalPlace = Convert.ToInt32(System.Configuration.ConfigurationManager.AppSettings["SiteDecimalPlace"].ToString()); db = new dbTIREntities(); SiteUser su = ((SiteUser)Session["SiteUser"]); ModelServices service = new ModelServices(); assessmentClassScoreService = new AssessmentClassScoreService(su, db); var details = assessmentClassScoreService.GetClassAssessmentScoreData(su.Districts.First().Id, model); model.ScoresDetails = details; SetDetailReportUrlData(model); if (model.ScoresDetails.Count > 0) { UpdateReportTemplateConfigurations(service, model.ScoresDetails[0].ReportTemplateId); } // service.IsChildAssessmentsExists(model.AssessmentList); }
public ActionResult UpdateGrid(FilterParameter filterParameter) { try { SetNavigationLinksUrl(); SetViewBag(filterParameter.ViewMeetExceedSummary); ViewBag.SummaryLink = "UpdateGrid"; bool unAuthorizedRequest = false; SiteUser su = ((SiteUser)Session["SiteUser"]); ModelServices modelServices = new ModelServices(); TIRSummaryModel data = new TIRSummaryModel(); int defaultDistrict = su.Districts[0].Id; data.DropDown = new DropDownData(); ViewBag.FilterParameter = filterParameter; #region Initializations var dropdownSchools = modelServices.GetSchoolDropDownData(su.EdsUserId, filterParameter.Year); var schoolCount = dropdownSchools.Where(x => x.Id == filterParameter.School).Count(); unAuthorizedRequest = schoolCount == 0 ? true : false; if (unAuthorizedRequest) { return RedirectToAction("AccessDenied", "Error"); } if (!unAuthorizedRequest) { if (su.isTeacher) { unAuthorizedRequest = (su.EdsUserId != filterParameter.Teacher) ? true : false; if (!unAuthorizedRequest) data.DropDown.Teacher = new TeacherDropDown(new List<DropDownIdName>() { new DropDownIdName() { Id = su.EdsUserId, Name = su.UserFullName } }); } else { var dropdownTeachers = modelServices.TeacherDropDownDataBySchoolAndYear(new int[] { filterParameter.School }, filterParameter.Year, defaultDistrict); unAuthorizedRequest = dropdownTeachers.Where(x => x.Id == filterParameter.Teacher).Count() == 0 ? true : false; if (!unAuthorizedRequest) { data.DropDown.Teacher = new TeacherDropDown(dropdownTeachers); data.DropDown.Teacher.SelectedTeacher = filterParameter.Teacher; } } } #endregion //TODO: need to refactor below code if possible. ViewBag.TeacherFilter = filterParameter.Teacher; ViewBag.SchoolFilter = filterParameter.School; ViewBag.YearFilter = filterParameter.Year; ViewBag.ClassFilter = filterParameter.ClassId; ViewBag.Race = filterParameter.Race; ViewBag.Gender = filterParameter.Gender; ViewBag.FrlIndicator = filterParameter.FrlIndicator; ViewBag.IEPIndicator = filterParameter.IEPIndicator; ViewBag.LEPIndicator = filterParameter.LEPIndicator; ViewBag.Hispanic = filterParameter.Hispanic; #region Init Filter Parameters data.SchoolYear = modelServices.SchoolYearDescriptionByYearId(filterParameter.Year); data.DropDown.Year = new YearDropDown(modelServices.SchoolYearDropDownData()); data.DropDown.Year.SelectedYear = filterParameter.Year; data.DropDown.District = new DistrictDropDown(modelServices.DistrictDropDownDataByUser(su.EdsUserId)); data.DropDown.School = new SchoolDropDown(dropdownSchools); data.DropDown.School.SelectedSchool = filterParameter.School; data.SummaryList = modelServices.GetSummaryReport(filterParameter); data.DropDown.SchoolClass = new ClassDropDown(modelServices.GetClassesByTeacher(filterParameter.Year, new[] { filterParameter.Teacher })); data.DropDown.Race = new RaceDropDown(modelServices.DropDownDataForRace(), true); data.DropDown.Race.SelectedRace = filterParameter.Race; data.DropDown.Gender = new GenderDropDown(modelServices.DropDownDataForGender(), true); data.DropDown.Gender.SelectedGender = filterParameter.Gender; data.Hispanic = filterParameter.Hispanic; data.IepIndicator = filterParameter.IEPIndicator; data.LepIndicator = filterParameter.LEPIndicator; data.FrlIndicator = filterParameter.FrlIndicator; data.DropDown.SchoolClass.SelectedClass = filterParameter.ClassId; #endregion filterParameter.SchoolYear = data.SchoolYear; var reportFilterViewModel = ReportsFilterHelper.PopulateReportFilterViewModel(filterParameter, modelServices, su); ViewBag.ReportFilters = reportFilterViewModel; return View("SummaryReport", data); } catch (Exception ex) { Logging log = new Logging(); log.LogException(ex); return View("GeneralError"); } }