public ActionResult Edit(Instructor instructor)
 {
     if (ModelState.IsValid)
     {
         db.Entry(instructor).State = EntityState.Modified;
         db.SaveChanges();
         return RedirectToAction("Index");
     }
     return View(instructor);
 }
Ejemplo n.º 2
0
 private void CreatesInstructorDataAndAssignsRole(Student currentUser)
 {
     var newInstructor = new Instructor
         {
             UserName = User.Identity.Name,
             EnrollmentDate = DateTime.Now,
             LastName = currentUser.LastName,
             FirstMidName = currentUser.FirstMidName,
             Email = currentUser.Email
         };
     db.Instructors.Add(newInstructor);
     db.SaveChanges();
     if (!User.IsInRole("Instructor"))
     {
         Roles.AddUserToRole(User.Identity.Name, "Instructor");
     }
 }
Ejemplo n.º 3
0
 private void BuildNotificationData(
     ApplyCourseViewModel appliedCourse, Instructor instructorAgain, Course newCourse)
 {
     var newNotification = new Notification
         {
             Time = DateTime.Now,
             Details =
                 "An Instructor by the name of " + instructorAgain.LastName + " has applied to teach "
                 + appliedCourse.Title,
             Link = Url.Action("Details", "Course", new { id = newCourse.CourseID }),
             ViewableBy = "Admin",
             Complete = false
         };
     db.Notification.Add(newNotification);
 }
Ejemplo n.º 4
0
 private Course BuildCourseData(ApplyCourseViewModel appliedCourse, Instructor instructorAgain)
 {
     Debug.Write(appliedCourse.Cost);
     var newCourse = new Course
         {
             Title = appliedCourse.Title,
             Credits = appliedCourse.Credits,
             Elective = appliedCourse.Elective,
             InstructorID = instructorAgain.InstructorID,
             Year = appliedCourse.StartDate.Year,
             AttendingDays = appliedCourse.AttendingDays,
             AttendanceCap = appliedCourse.AttendanceCap,
             StartDate = appliedCourse.StartDate,
             EndDate = appliedCourse.EndDate,
             Location = appliedCourse.Location,
             Parish = appliedCourse.Parish,
             Description = appliedCourse.Description,
             Cost = appliedCourse.Cost,
             Approved = false,
             Completed = false,
             Archived = false
         };
     db.Courses.Add(newCourse);
     return newCourse;
 }
Ejemplo n.º 5
0
        // GET: /Account/Profile
        /// <summary>
        /// The update instructors table with updated profile data from profile view model.
        /// </summary>
        /// <param name="model">
        /// The model.
        /// </param>
        /// <param name="isInstructor">
        /// The is instructor.
        /// </param>
        private void UpdateInstructorsTableWithUpdatedProfileDataFromProfileViewModel(
            ProfileViewModel model, Instructor isInstructor)
        {
            isInstructor.LastName = model.LastName;
            isInstructor.FirstMidName = model.FirstMidName;
            MembershipUser u = Membership.GetUser(User.Identity.Name);

            // needed to get email for isInstructor.Email = u.Email;
            if (u != null)
            {
                isInstructor.Email = u.Email;
            }

            db.SaveChanges();
        }
        public ActionResult ApproveInstructorApplication(int id)
        {
            InstructorApplication instructorApplication = db.InstructorApplication.Find(id);
            instructorApplication.Approved = true;

            var instructor = new Instructor
                                 {
                                     UserName = instructorApplication.Student.UserName,
                                     LastName = instructorApplication.Student.LastName,
                                     FirstMidName = instructorApplication.Student.FirstMidName,
                                     Email = instructorApplication.Student.Email,
                                     EnrollmentDate = DateTime.Now
                                 };
            db.Instructors.Add(instructor);

            var newNotification = new Notification
                                      {
                                          Time = DateTime.Now,
                                          Details =
                                              "An Admin has approved your application to become an Instructor as of " +
                                              DateTime.Now,
                                          Link =
                                              Url.Action(
                                                  "Details",
                                                  "InstructorApplication",
                                                  new {id = instructorApplication.InstructorApplicationID}),
                                          ViewableBy = instructor.UserName,
                                          Complete = false
                                      };
            db.Notification.Add(newNotification);

            db.SaveChanges();

            if (!(Roles.IsUserInRole(instructor.UserName, "Instructor")))
            {
                Roles.AddUserToRole(instructor.UserName, "Instructor");
            }

            return View("Success");

            //Roles.AddUserToRole(, "Instructor");
            // make user an instructor
            // //  need to set user.role to "Instructor"
            // //  need to pull data from Student Table into Instructor table (actually need to rework the non-dry components of this feature,
            // //  but that is for another time).
            // Create notification for Instructor
            // visually notify Admin that the change has been made.
        }