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: /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 Index()
        {
            try
            {
                if (User.Identity.IsAuthenticated)
                {
                    // Refresh the session object
                    var userManager = new UserManager<ApplicationUser>(new UserStore<ApplicationUser>(new ApplicationDbContext()));
                    HelperService.SetSiteUserProfile(userManager.FindByName(User.Identity.Name), new dbTIREntities());
                }

                if (User.IsInRole("Adminstrator"))
                {
                    Session["UserIsAdmin"] = true;
                    //return list of teacher in my scope
                    return View();
                }
                else
                { Session["UserIsAdmin"] = false; }
                return View();
            }
            catch (Exception ex)
            {
                Logging log = new Logging();
                log.LogException(ex);
                return View("GeneralError");
            }
        }
 public ActionResult Edit(int studentId, string schoolYear, string schoolTerm, string assessmentType, string assessmentDesc, string localId, string subject)
 {
     try
     {
         if (TempData["AssessmentModel"] != null)
         {
             TempData["AssessmentModel"] = TempData["AssessmentModel"];
         }
         dbTIREntities db = new dbTIREntities();
         SiteUser siteUser = ((SiteUser)Session["SiteUser"]);
         assScoreService = new AssessmentScoreService(siteUser, db);
         List<StudentScore> studentScores = assScoreService.GetStudentAssessmentScore(studentId, schoolYear, schoolTerm, assessmentType, assessmentDesc, localId, subject);
         StudentScore score = studentScores.FirstOrDefault();
         //StudentExt studentExt = studentService.GetStudentDetail(studentId, schoolYear);
         //PopulateViewData(studentExt);
         // ViewBag.AllowEdit = HelperService.AllowUiEdits(siteUser.RoleDesc, "STUDENT");
         return View(score);
     }
     catch (Exception ex)
     {
         Logging log = new Logging();
         log.LogException(ex);
         return View("GeneralError");
     }
 }
        //
        // GET: /AssessmentClassScore/
        public ActionResult Search(AssessmentClassScoreViewModel model)
        {
            try
            {
                db = new dbTIREntities();
                siteUser = ((SiteUser)Session["SiteUser"]);
                assessmentClassScoreService = new AssessmentClassScoreService(siteUser, db);

                if (assessmentClassScoreService.IsAssessmentWeightingExists(model))
                {
                    InitializeAssessmentScoreMetadata(model);
                    if (model.ScoresDetails.Count == 0)
                    {
                        ViewBag.Message = "No Record Found.";
                    }
                }
                else
                {
                    ViewBag.Message = "This combination of subject and assessment does not exist in the system for the selected school year.";
                }
                FillDropDowns(model, true);
                return View("Index", model);
            }
            catch (Exception ex)
            {
                Logging log = new Logging();
                log.LogException(ex);
                return View("GeneralError");
            }
        }
        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 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: /ClassStudentTeacher/
 public ActionResult Index()
 {
     try
     {
         var tblclasses = db.tblClasses.Include(t => t.tblSchool).Include(t => t.tblSchoolYear).Include(t => t.tblSubject);
         return View(tblclasses.ToList());
     }
     catch (Exception ex)
     {
         Logging log = new Logging();
         log.LogException(ex);
         return View("GeneralError");
     }
 }
 // GET: /ClassStudentTeacher/Create
 public ActionResult Create()
 {
     try
     {
         ViewBag.SchoolId = new SelectList(db.tblSchools, "SchoolId", "SchoolDesc");
         ViewBag.SchoolYearId = new SelectList(db.tblSchoolYears, "SchoolYearId", "SchoolYearDesc");
         ViewBag.SubjectId = new SelectList(db.tblSubjects, "SubjectId", "SubjectDesc");
         return View();
     }
     catch (Exception ex)
     {
         Logging log = new Logging();
         log.LogException(ex);
         return View("GeneralError");
     }
 }
 public ActionResult SaveAssessmentClassScore(List<AssessmentClassScore> model)
 {
     try
     {
         db = new dbTIREntities();
         SiteUser su = ((SiteUser)Session["SiteUser"]);
         assessmentClassScoreService = new AssessmentClassScoreService(su, db);
         string result = assessmentClassScoreService.SaveClassAssessmentScore(model);
         return Json(result, JsonRequestBehavior.AllowGet);
     }
     catch (Exception ex)
     {
         Logging log = new Logging();
         log.LogException(ex);
         return View("GeneralError");
     }
 }
        public ActionResult KnowledgeBaseDetail(int KnowledgeBaseId)
        {
            try
            {
                var db = new dbTIREntities();
                SiteUser su = (SiteUser)Session["SiteUser"];
                KnowledgeBaseService kbService = new KnowledgeBaseService(su, db);
                int DistrictId = su.Districts[0].Id;
                var listdata = kbService.GetKnowledgeBaseDetail(KnowledgeBaseId, DistrictId);
                return View(listdata);

            }
            catch (Exception ex)
            {
                Logging log = new Logging();
                log.LogException(ex);
                return View("GeneralError");
            }
        }
 public ActionResult Index()
 {
     try
     {
         var db = new dbTIREntities();
         SiteUser su = (SiteUser)Session["SiteUser"];
         KnowledgeBaseService kbService = new KnowledgeBaseService(su, db);
         List<KnowledgeBase> KnowledgeBaseItems = new List<KnowledgeBase>();
         KnowledgeBaseItems = kbService.GetKnowledgeBase().ToList();
         ViewBag.AllowEdit = HelperService.AllowUiEdits(su.RoleDesc, "USER");
         return View(KnowledgeBaseItems);
     }
     catch (Exception ex)
     {
         Logging log = new Logging();
         log.LogException(ex);
         return View("GeneralError");
     }
 }
Exemplo n.º 13
0
        public ActionResult GetAnnouncements()
        {
            try
            {
                var db = new dbTIREntities();
                SiteUser su = (SiteUser)Session["SiteUser"];
                SupportService supportService = new SupportService(su, db);

                return PartialView("_AnnouncementPartial", new SiteModels() 
                { 
                    Announcements = supportService.GetAnnouncements().ToList() 
                }); 
            }
            catch (Exception ex)
            {
                Logging log = new Logging();
                log.LogException(ex);
                return View("GeneralError");
            }
        }
        public ActionResult Announcements(int? page)
        {
            try
            {
                int pageSize = Convert.ToInt32(ConfigurationManager.AppSettings["PageSize"]);
                int pageNumber = (page ?? 1);
                var db = new dbTIREntities();
                SiteUser su = (SiteUser)Session["SiteUser"];
                SupportService supportService = new SupportService(su, db);   
                var listData = (supportService.GetAnnouncements()).ToPagedList(pageNumber, pageSize);
                return View("Announcements", listData);
            }
            catch (Exception ex)
            {
                Logging log = new Logging();
                log.LogException(ex);
                return View("GeneralError");
            }

        }
Exemplo n.º 15
0
 public ActionResult Search(string search, string schoolFilterSearch, string schoolYearSearch)
 {
     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(schoolYearSearch);
         int schoolYearId = modelService.GetSchoolYearId(Convert.ToInt32(schoolYearSearch));
         FillViewBagValues(siteUser.Districts[0].Name, schoolFilterSearch, siteUser.RoleDesc, schoolYearId);
         return View("Index", userService.GetViewData(schoolYearSearch, schoolFilterSearch, search));
     }
     catch (Exception ex)
     {
         Logging log = new Logging();
         log.LogException(ex);
         return View("GeneralError");
     }
 }
 // GET: /ClassStudentTeacher/Details/5
 public ActionResult Details(int? id)
 {
     try
     {
         if (id == null)
         {
             return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
         }
         tblClass tblclass = db.tblClasses.Find(id);
         if (tblclass == null)
         {
             return HttpNotFound();
         }
         return View(tblclass);
     }
     catch (Exception ex)
     {
         Logging log = new Logging();
         log.LogException(ex);
         return View("GeneralError");
     }
 }
Exemplo n.º 17
0
 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 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");
            }
        }
 public async Task<ActionResult> Login(LoginViewModel model, string returnUrl)
 {
     try
     {
         if (ModelState.IsValid)
         {
             var user = await UserManager.FindAsync(model.UserName, model.Password);
             if (user != null)
             {
                 
                 if (HelperService.IsUserAuthorized(user, new dbTIREntities()))
                 {
                     await SignInAsync(user, model.RememberMe);
                     // Place user's profile object into session.
                     SiteUser siteUser = HelperService.SetSiteUserProfile(user, new dbTIREntities());
                     // Record user last logged in info.
                     HelperService.SetUserLoginInfo(siteUser, new dbTIREntities());
                     // Let user in!
                     return RedirectToLocal(returnUrl);
                 }
                 else
                 {
                     ModelState.AddModelError("", "This account is not authorized for the current school year. Please contact your administrator or EDS support if this is incorrect.");
                 }
             }
             else
             {
                 ModelState.AddModelError("", "Invalid username or password.");
             }
         }
     }
     catch (Exception ex)
     {
         Logging log = new Logging();
         log.LogException(ex);
         return View("GeneralError");
     }
     // If we got this far, something failed, redisplay form
     return View(model);
 }
Exemplo n.º 20
0
 private void FillViewBagValues(string districtName, string school, string roleDesc, int schoolYearId)
 {
     try
     {
         ViewBag.DistrictDesc = districtName;
         ViewBag.SchoolId = modelService.DropDownDataSchool(school, siteUser.EdsUserId, schoolYearId, true);
         ViewBag.AllowEdit = HelperService.AllowUiEdits(roleDesc, "USER");
     }
     catch (Exception ex)
     {
         Logging log = new Logging();
         log.LogException(ex);
     }
 }
Exemplo n.º 21
0
        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");
            }
        }
Exemplo n.º 22
0
        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");
            }
        }
Exemplo n.º 23
0
        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");
            }
        }
Exemplo n.º 24
0
        // 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 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");
            }
        }
        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 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");
            }
        }
        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");
            }
        }
        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");
            }
        }
        public ActionResult Edit([Bind(Include = "StudentId,StudentSchoolYearId,SchoolYearId,DistrictId,FirstName,MiddleName,LastName,BirthDate,Hispanic,StateId,LocalId,EnrollmentDate,IepIndicator,LepIndicator,FrlIndicator,")] StudentExt studentExt, int hdSchoolId, int? hdLineageId, int hdGradeId, int hdGenderId, int? hdRaceId, int? hdHomeLanguageId, int? hdNativeLanguageId, int schoolYear)
        {
            try
            {
                dbTIREntities db = new dbTIREntities();
                SiteUser siteUser = ((SiteUser)Session["SiteUser"]);
                StudentService studentService = new StudentService(siteUser, db);
                ViewBag.AllowEdit = HelperService.AllowUiEdits(siteUser.RoleDesc, "STUDENT");
                if (ModelState.IsValid)
                {
                    studentExt.ServingSchoolId = hdSchoolId;
                    studentExt.LineageId = hdLineageId;
                    studentExt.NativeLanguageId = hdNativeLanguageId;
                    studentExt.HomeLanguageId = hdHomeLanguageId;
                    studentExt.RaceId = hdRaceId;
                    studentExt.GradeLevel = (short)hdGradeId;
                    studentExt.GenderId = hdGenderId;
                    studentExt.SchoolYear = schoolYear;
                    if (studentService.IsStudentExist(studentExt.StateId, null, studentExt.StudentId))
                    {
                        PopulateViewData(studentExt);
                        ModelState.AddModelError("StateId", "State Id already exists");
                        return View(studentExt);
                    }
                    else if (studentService.IsStudentExist(null, studentExt.LocalId, studentExt.StudentId))
                    {
                        PopulateViewData(studentExt);
                        ModelState.AddModelError("LocalId", "Local Id already exists");
                        return View(studentExt);
                    }
                    else
                    {
                        studentService.SaveStudents(studentExt);
                    }
                }

                return RedirectToAction("Index");
            }
            catch (Exception ex)
            {
                Logging log = new Logging();
                log.LogException(ex);
                return View("GeneralError");
            }
        }