public ActionResult RequestStatus() { try { if (User.IsInRole("Student")) { if (!WebSettings.IsValidationOpen()) { return(RedirectToAction("StudentScholarship")); } ViewBag.errorMessage = TempData["errorMessage"]; return(View(studentActions.GetMyRequest(WebSettings.CurrentPeriod().PeriodID, User.Identity.GetUserId()))); } else { TempData["errorMessage"] = "Sorry you do not have access."; return(RedirectToAction("Announcement", "WebsiteContent")); } } catch (Exception e) { ViewBag.errorMessage = "There was an error in displaying your validation requests. Please try again, thank you!" + e.ToString(); return(View()); } }
public ActionResult Scholars(int? scholarshipID) { List<PreValidatedStudent> scholarList = null; try { if(scholarshipID == null) { return RedirectToAction("ScholarSelection"); } else { scholarList = websiteActions.GetScholarsByScholarshipID((int)scholarshipID) .Where(model => model.PeriodID == WebSettings.CurrentPeriod().PeriodID) .OrderBy(model => model.AspNetUser.UserProfiles.FirstOrDefault().StudentProfile.LastName) .ToList(); if(scholarList.Count() > 0) { return View(scholarList); } TempData["errorMessage"] = "Sorry but there are no scholars for that scholarship."; return RedirectToAction("ScholarSelection"); } } catch (Exception e) { TempData["errorMessage"] = "Sorry there was an error in displaying the the list of scholars. Please try again."; return RedirectToAction("ScholarSelection"); } }
public ActionResult Index(string status = "Queue") { List <ValidationRequest> requests = null; ViewBag.Status = status; if (db.ValidationStatus.Where(e => e.StatusName.Equals(status)).FirstOrDefault() == null) { ViewBag.Message = "Validation Status not found"; return(View()); } int currentPeriodID = WebSettings.CurrentPeriod().PeriodID; requests = db.ValidationRequests.Where(e => e.ValidationStatu.StatusName.Equals(status) && e.PeriodID == currentPeriodID).ToList(); return(View(requests)); }
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)); } }
public ActionResult ValidateScholarship(int?scholarshipID) { try { if (User.IsInRole("Student")) { if (scholarshipID == null) { return(RedirectToAction("StudentScholarship")); } else { bool isScholarshipSiblingDiscount = studentActions.GetScholarshipByID((int)scholarshipID).ScholarshipName.ToLower() == "sibling discount" ? true:false; ViewBag.isScholarshipSiblingDiscount = isScholarshipSiblingDiscount; bool isStudentPassedApplicationForm = studentActions.IsStudentPassedApplicationForm((int)scholarshipID, User.Identity.GetUserId()); ViewBag.isStudentPassedApplicationForm = isStudentPassedApplicationForm; return(View(new ValidationRequest() { ScholarshipID = (int)scholarshipID, DateFilled = DateTime.Now, UserID = User.Identity.GetUserId(), StatusID = 1, //1 == approved PeriodID = WebSettings.CurrentPeriod().PeriodID, Processed = false, Remarks = " " })); } } else { TempData["errorMessage"] = "Sorry you do not have access."; return(RedirectToAction("Announcement", "WebsiteContent")); } } catch (Exception e) { TempData["errorMessage"] = "There was an error. Please try again, thank you!" + e.ToString(); return(RedirectToAction("StudentScholarship")); } }
public ActionResult ScholarshipValidationForm(int?scholarshipID) { try { if (User.IsInRole("Student")) { if (scholarshipID == null) { return(RedirectToAction("StudentScholarship")); } else { ViewBag.AcademicYear = WebSettings.CurrentPeriod().AcademicYearStart + "-" + WebSettings.CurrentPeriod().AcademicYearEnd; ViewBag.Term = WebSettings.CurrentPeriod().Term; string userID = User.Identity.GetUserId(); //if student has passed a scholarship application form for that scholarship, dummy table if (StudentActions.IsAVoucher(studentActions.GetScholarshipByID((int)scholarshipID))) { if (studentActions.IsScholarshipRequested((int)scholarshipID, User.Identity.GetUserId(), 1, WebSettings.CurrentPeriod().PeriodID)) { TempData["errorMessage"] = "A voucher has already been requested. Please check the status."; return(RedirectToAction("StudentScholarship")); } else { ViewBag.ScholarshipName = studentActions.GetScholarshipName((int)scholarshipID); ViewBag.ScholarshipID = (int)scholarshipID; return(View(studentActions.GetDBObject().AspNetUsers.Where(model => model.Id == userID).FirstOrDefault())); } } else //not a voucher { if (studentActions.IsScholarshipRequested((int)scholarshipID, User.Identity.GetUserId(), 2, WebSettings.CurrentPeriod().PeriodID)) { TempData["errorMessage"] = "You already have ascholarship. Please check the status."; return(RedirectToAction("StudentScholarship")); } ///non listed meaning, walang listahan ng scholars. else if (StudentActions.IsScholarshipNonListed(studentActions.GetScholarshipByID((int)scholarshipID).ScholarshipName.ToLower())) { ViewBag.ScholarshipName = studentActions.GetScholarshipName((int)scholarshipID); ViewBag.ScholarshipID = (int)scholarshipID; return(View(studentActions.GetDBObject().AspNetUsers.Where(model => model.Id == userID).FirstOrDefault())); } else { ViewBag.ScholarshipName = studentActions.GetScholarshipName((int)scholarshipID); ViewBag.ScholarshipID = (int)scholarshipID; return(View(studentActions.GetDBObject().AspNetUsers.Where(model => model.Id == userID).FirstOrDefault())); } } } } else { TempData["errorMessage"] = "Sorry you do not have access."; return(RedirectToAction("Announcement", "WebsiteContent")); } } catch (Exception e) { TempData["errorMessage"] = "There was an error. Please try again, thank you!" + e.ToString(); return(RedirectToAction("StudentScholarship")); } }
public async Task RegisterAccountAsync(RegisterViewModel model) { var user = new ApplicationUser { UserName = model.Email, Email = model.Email }; var result = await UserManager.CreateAsync(user, model.Password); //create user profile AspNetUser netUser = db.AspNetUsers.Where(tuser => tuser.Id.Equals(user.Id)).FirstOrDefault(); netUser.PeriodID = WebSettings.CurrentPeriod().PeriodID; netUser.ValidationPeriod = db.ValidationPeriods.Where(e => e.PeriodID == netUser.PeriodID).FirstOrDefault(); StudentProfile studentProfile = db.StudentProfiles.Where(e => e.Email.Equals(model.Email)).FirstOrDefault(); //Assign Profile UserProfile userProfile = new UserProfile(); userProfile.AspNetUser = netUser; userProfile.StudentProfile = studentProfile; userProfile.ProfileID = studentProfile.ProfileID; userProfile.UserID = netUser.Id; db.UserProfiles.Add(userProfile); // Assign user role AspNetRole role = db.AspNetRoles.Where(trole => trole.Name.Equals("Student")).FirstOrDefault(); AspNetUserRole userRole = new AspNetUserRole { AspNetRole = role, AspNetUser = netUser, RoleId = role.Id, UserId = user.Id }; db.AspNetUserRoles.Add(userRole); // add user program int programID = db.Programs.Where(e => e.ProgramName.Equals(studentProfile.Program)).FirstOrDefault().ProgramID; int year = studentProfile.Year; Program program = db.Programs.Where(tPrg => tPrg.ProgramID.Equals(programID)).FirstOrDefault(); UserProgram userProgram = new UserProgram() { AspNetUser = netUser, ProgramID = programID, Program = program, UserID = user.Id, Year = year }; db.UserPrograms.Add(userProgram); if (!result.Succeeded) { AddErrors(result); } db.SaveChanges(); // Send Verification link string code = await UserManager.GenerateEmailConfirmationTokenAsync(user.Id); var callbackUrl = Url.Action("ConfirmEmail", "Account", new { userId = user.Id, code = code }, protocol: Request.Url.Scheme); await UserManager.SendEmailAsync(user.Id, "Confirm your account", "Please confirm your account by clicking <a href=\"" + callbackUrl + "\">here</a>"); }