public ActionResult Edit(Notification notification)
 {
     if (ModelState.IsValid)
     {
         db.Entry(notification).State = EntityState.Modified;
         db.SaveChanges();
         return RedirectToAction("Index");
     }
     return View(notification);
 }
        public ActionResult Create(Notification notification)
        {
            if (ModelState.IsValid)
            {
                db.Notification.Add(notification);
                db.SaveChanges();
                return RedirectToAction("Index");
            }

            return View(notification);
        }
Exemplo n.º 3
0
 private void BuildNotificationData(Course course)
 {
     var newNotification = new Notification
         {
             Time = DateTime.Now,
             Details =
                 "An Administrator has approved your application to teach " + course.Title + " beginning "
                 + course.StartDate,
             Link = Url.Action("AttendanceView", "Attendance", new { id = course.CourseID }),
             ViewableBy = course.Instructor.UserName,
             Complete = false
         };
     db.Notification.Add(newNotification);
 }
Exemplo n.º 4
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);
 }
Exemplo n.º 5
0
 private void BuildNotificationData(Course course, Student thisStudent)
 {
     var newNotification = new Notification
         {
             Time = DateTime.Now,
             Details =
                 "A Student by the name of " + thisStudent.FirstMidName + " " + thisStudent.LastName
                 + " has signed up for " + course.Title,
             Link = Url.Action("Details", "Student", new { id = thisStudent.StudentID }),
             ViewableBy = "Admin",
             Complete = false
         };
     db.Notification.Add(newNotification);
 }
Exemplo n.º 6
0
        public ActionResult EditCourse(Course course)
        {
            if (ModelState.IsValid)
            {
                db.Entry(course).State = EntityState.Modified;

                Instructor thisInstructor = db.Instructors.FirstOrDefault(o => o.InstructorID == course.InstructorID);

                // Add a notification for the Instructor to see that the Course was modified
                var newNotification = new Notification
                    {
                        Time = DateTime.Now,
                        Details =
                            "An Admin has edited the course you applied to teach: " + course.Title + " beginning "
                            + course.StartDate,
                        Link = Url.Action("Details", "Course", new { id = course.CourseID }),
                        // ViewableBy = course.Instructor.UserName,
                        ViewableBy = thisInstructor.UserName,
                        Complete = false
                    };
                db.Notification.Add(newNotification);
                db.SaveChanges();
                TempData["tempMessage"] =
                    "You have successfully applied edited this course.  A notification has been sent to the instructor who applied to teach this course.";
                return RedirectToAction("Index");
            }

            return View(course);
        }
Exemplo n.º 7
0
        public ActionResult DeleteConfirmed(int id, Course hasReasonForDeletion)
        {
            Course course = db.Courses.Find(id);

            // Add the notification for the Instructor that their Course has been unapproved
            var newNotification = new Notification
                {
                    Time = DateTime.Now,
                    Details =
                        "An Administrator has denied your application to teach " + course.Title
                        + " citing the following reason: " + hasReasonForDeletion.AdminDenialReason,
                    Link = Url.Action("ApplyToTeach", "Course", new { id = course.CourseID }),
                    ViewableBy = course.Instructor.UserName,
                    Complete = false
                };
            db.Notification.Add(newNotification);

            db.Courses.Remove(course);
            db.SaveChanges();
            return RedirectToAction("Index", "Notification");
        }
 private Notification BuildNewNotification(InstructorApplication instructorApplication, Student thisUser)
 {
     var newNotification = new Notification
                               {
                                   Time = DateTime.Now,
                                   Details =
                                       "A user by the name of " + thisUser.FirstMidName + " " + thisUser.LastName
                                       + " has applied to become an Instructor",
                                   Link =
                                       Url.Action(
                                           "Details",
                                           "InstructorApplication",
                                           new {id = instructorApplication.InstructorApplicationID}),
                                   ViewableBy = "Admin",
                                   Complete = false
                               };
     return newNotification;
 }
        public ActionResult Delete(int id)
        {
            InstructorApplication application = db.InstructorApplication.Find(id);

            var newNotification = new Notification
                                      {
                                          Time = DateTime.Now,
                                          Details =
                                              "An Administrator has denied and deleted your application to become an Instructor. Contact the St. Paul School of Catechesis at 361-882-6191.",
                                          Link = Url.Action("ApplyToBecomeInstructor"),
                                          ViewableBy = application.Student.UserName,
                                          Complete = false
                                      };
            db.Notification.Add(newNotification);
            db.SaveChanges();

            IEnumerable<EducationalBackground> listOfEducationalBackgrounds =
                db.EducationalBackground.Where(
                    o => o.InstructorApplication.InstructorApplicationID == application.InstructorApplicationID);
            foreach (EducationalBackground item in listOfEducationalBackgrounds)
            {
                db.EducationalBackground.Remove(item);
            }
            db.InstructorApplication.Remove(application);
            db.SaveChanges();
            return RedirectToAction("Index", "Notification");
        }
        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.
        }