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");
     }
 }
 public ActionResult Index()
 {
     db = new dbTIREntities();
     siteUser = ((SiteUser)Session["SiteUser"]);
     assScoreService = new AssessmentScoreService(siteUser, db);
     commonService = new CommonService(siteUser, db);
     AssessmentScoreViewModel model = new AssessmentScoreViewModel();
     model.DistrictName = siteUser.Districts[0].Name;
     model.DistrictId = siteUser.Districts[0].Id;
     FillDropDowns(model);
     return View(model);
 }
 public ActionResult Search(AssessmentScoreViewModel model)
 {
     db = new dbTIREntities();
     siteUser = ((SiteUser)Session["SiteUser"]);
     assScoreService = new AssessmentScoreService(siteUser, db);
     model.DistrictName = siteUser.Districts[0].Name;
     model.DistrictId = siteUser.Districts[0].Id;
     model.StudentScores = assScoreService.GetAssessmentScoreData(model);
     FillDropDowns(model);
    TempData["AssessmentModel"] = model;
     return View("Index", model);
 }
        public ActionResult Edit(
            [Bind(
                Include =
                    "Subject,LocalId,StudentId,FirstName,LastName,Score,AssessmentType,SchoolTerm,SchoolYear,AssessmentDesc,AssessmentId"
                )] StudentScore studentScore)
        {
            try
            {
                dbTIREntities db = new dbTIREntities();
                SiteUser siteUser = ((SiteUser)Session["SiteUser"]);
                AssessmentScoreService assessmentService = new AssessmentScoreService(siteUser, db);
                ViewBag.AllowEdit = HelperService.AllowUiEdits(siteUser.RoleDesc, "STUDENT");

                tblAssessmentScore assscore =
                    db.tblAssessmentScores.Where(
                        k => k.AssessmentId == studentScore.AssessmentId && k.StudentId == studentScore.StudentId)
                        .ToList()
                        .FirstOrDefault();
                assscore.Score = studentScore.Score;

                assessmentService.UpdateStudentScore(assscore);
                return RedirectToAction("Search", TempData["AssessmentModel"]);
                //  return RedirectToAction("Index");
            }
            catch (Exception ex)
            {
                Logging log = new Logging();
                log.LogException(ex);
                return View("GeneralError");
            }

        }
 private void FillDropDowns(AssessmentScoreViewModel model)
 {
     siteUser = ((SiteUser)Session["SiteUser"]);
     commonService = new CommonService(siteUser, db);
     assScoreService = new AssessmentScoreService(siteUser, db);
     model.AssessmentTypes = commonService.GetAssessmentType();
     model.SchoolYears = commonService.GetSchoolYear();
     model.SchoolTerms = commonService.GetSchoolTerm();
 }