示例#1
0
        public ActionResult StudentScholarship()
        {
            List <PreValidatedStudent> scholarships = null;

            try
            {
                if (User.IsInRole("Student"))
                {
                    ViewBag.IsValidationOpen = WebSettings.IsValidationOpen();
                    if (!WebSettings.IsValidationOpen())
                    {
                        ViewBag.ValidationMessage = "Scholarship validation is not yet open.";
                        return(View());
                    }

                    ViewBag.errorMessage = TempData["errorMessage"];

                    ViewBag.NonListedScholarship = studentActions.GetDBObject().Scholarships.Where(
                        model => model.ScholarshipName.ToLower() == "sibling discount" ||
                        model.ScholarshipName.ToLower() == "ygc promotional discount" ||
                        model.ScholarshipName.ToLower() == "mcl study aid"
                        ).ToList();

                    scholarships = studentActions.GetAllScholars()
                                   .Where(model => model.UserID == User.Identity.GetUserId() &&
                                          model.PeriodID == WebSettings.CurrentPeriod().PeriodID)
                                   .Distinct()
                                   .ToList();

                    return(View(scholarships));
                }
                else
                {
                    TempData["errorMessage"] = "Sorry you do not have access.";
                    return(RedirectToAction("Announcement", "WebsiteContent")); //maybe use content with the navbar for easy navigation, no sense if redirected to announcement
                }
            }
            catch (Exception e)
            {
                ViewBag.errorMessage = "There was an error in displaying your scholarships. Please try again, thank you!";
                return(View(scholarships));
            }
        }