Exemple #1
0
        public ActionResult StudentBio(StudentBioViewModel model)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    DateTime timeLimit = DateTime.Now.AddDays(-15);
                    string   year      = DateTime.Now.Year.ToString();
                    int      semester  = DateTime.Now.Month < 7 ? 1 : 2;

                    model.Student    = context.Students.First(m => m.IdNumber == model.StudentIdNumber);
                    model.Clearances = context.Clearances.Include("Reason").Where(m => m.Student.Id == model.Student.Id).Where(m => m.RequestDate > timeLimit).ToList();

                    model.CurrentCourses = context.StudentCourses.Include("Student").Include("Course").Where(m => m.StudentId == model.Student.Id).Where(m => m.Year == year).Where(m => m.Semester == semester).ToList();

                    model.Loans = context.Loans.Where(m => m.StudentId == model.Student.Id).Where(m => m.ReturnDate == null).ToList();

                    model.Grades = context.StudentCourses.Include("Student").Include("Course").Include("Grade").Where(c => c.StudentId == model.Student.Id).ToList();
                }
                catch (Exception)
                {
                    ModelState.AddModelError(String.Empty, "There is no student with that ID number");
                }
            }
            return(View(model));
        }
Exemple #2
0
        public ActionResult ResetStudentPassword(StudentBioViewModel model)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    string  password     = "******" + new Random().Next(1000, 9999).ToString() + "-";
                    string  passwordHash = new PasswordHasher().HashPassword(password);
                    Student student      = context.Students.First(m => m.IdNumber == model.StudentIdNumber);
                    student.PasswordHash         = passwordHash;
                    context.Entry(student).State = EntityState.Modified;
                    context.SaveChanges();

                    TempData["SuccessMessage"] = "Password Reset, the new password is " + password;
                }
                catch (Exception)
                {
                }
            }
            return(RedirectToAction("StudentBio"));
        }
Exemple #3
0
        public ActionResult StudentBio()
        {
            StudentBioViewModel model = new StudentBioViewModel();

            return(View(model));
        }