Esempio n. 1
0
        public ActionResult ApplyToBecomeInstructor(InstructorApplicationViewModel applicationFromView)
        {
            try
            {
                Student thisUser = db.Students.FirstOrDefault(o => o.StudentID == applicationFromView.CurrentUserId);
                InstructorApplication instructorApplication = BuildNewInstructorApplicationAndAddToDb(applicationFromView,
                                                                                                      thisUser);

                db.SaveChanges();

                BuildNewNotificationAndAddToDb(instructorApplication, thisUser);

                db.SaveChanges();
                TempData["message"] =
                    "Your application to become an Instructor has been submitted and is awaiting Administrative review.  You will be notified via your notifications page when your application has been reviewed, this typically takes 1 - 3 business days.  Contact the St. Paul School of Catechesis at 361-882-6191 if you have any questions.";
                return(Redirect("Index"));
            }
            catch (DataException)
            {
                ModelState.AddModelError("",
                                         "Saving failed for some reason.  You may have left some information blank.  Please try again (several times in several different ways if possible (i.e. try using a different computer) - if the problem persists see your system administrator.");
            }
            TempData["message"] =
                "Your application to become an Instructor failed to submit.  A common reason for this error is blank spaces within the form.  Please fill all blanks and resubmit.  If the problem persists, contact the administrator.";
            return(RedirectToAction("ApplyToBecomeInstructor"));
        }
Esempio n. 2
0
        private static InstructorApplication BuildNewInstructorApplication(
            InstructorApplicationViewModel applicationFromView, Student thisUser)
        {
            var educationList = new List <EducationalBackground>();

            foreach (EducationalBackGround educate in applicationFromView.EducationalBackgrounds)
            {
                var education = new EducationalBackground
                {
                    YearReceived        = educate.YearReceived,
                    Degree              = educate.Degree,
                    AreaOfStudy         = educate.AreaOfStudy,
                    UniversityOrCollege = educate.UniversityOrCollege
                };
                educationList.Add(education);
            }
            var instructorApplication = new InstructorApplication
            {
                StudentID             = thisUser.StudentID,
                EducationalBackground = new List <EducationalBackground>(),
                Experience            = applicationFromView.Experience,
                WillingToTravel       = applicationFromView.WillingToTravel,
                Approved = false
            };

            instructorApplication.EducationalBackground.AddRange(educationList);
            return(instructorApplication);
        }
Esempio n. 3
0
        /// <summary>
        /// Allows a registered user to apply to become an Instructor
        /// </summary>
        /// <returns>
        /// The view needed to register to become an Instructor
        /// </returns>
        public ActionResult ApplyToBecomeInstructor()
        {
            Student        thisStudent = db.Students.FirstOrDefault(o => o.UserName == User.Identity.Name);
            IList <string> experiences = new List <string>
            {
                "0-1 year",
                "2-4 years",
                "5-7 years",
                "8-10 years",
                "Over 10 years"
            };
            var model = new InstructorApplicationViewModel
            {
                EducationalBackgrounds =
                    new List <EducationalBackGround>
                {
                    new EducationalBackGround
                    {
                        AreaOfStudy         = string.Empty,
                        Degree              = string.Empty,
                        UniversityOrCollege = string.Empty,
                        YearReceived        = string.Empty
                    }
                },
                CurrentUserId  = thisStudent.StudentID,
                ExperienceList = new SelectList(experiences),
            };

            return(View(model));
        }
Esempio n. 4
0
        private InstructorApplication BuildNewInstructorApplicationAndAddToDb(
            InstructorApplicationViewModel applicationFromView, Student thisUser)
        {
            InstructorApplication instructorApplication = BuildNewInstructorApplication(applicationFromView, thisUser);

            db.InstructorApplication.Add(instructorApplication);
            return(instructorApplication);
        }