Ejemplo n.º 1
0
        private bool AmountPaidIsValid(Course course, decimal amountPaid)
        {
            bool result = true;

            if (course != null)
            {
                if (course.Cost > amountPaid)
                {
                    result = false;
                }
            }
            return result;
        }
Ejemplo n.º 2
0
 private void CreateEnrollmentAttendanceAndNotificationData(Course course, Student thisStudent)
 {
     course.SeatsTaken = course.SeatsTaken + 1;
     BuildEnrollmentData(course, thisStudent);
     BuildAttendanceData(course, thisStudent);
     BuildNotificationData(course, thisStudent);
     db.SaveChanges();
 }
Ejemplo 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);
 }
Ejemplo 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);
 }
Ejemplo 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);
 }
Ejemplo n.º 6
0
 private void BuildEnrollmentData(Course course, Student thisStudent)
 {
     bool hasPaid = course.Cost == 0;
     var newEnrollment = new Enrollment
         {
             CourseID = course.CourseID,
             StudentID = thisStudent.StudentID,
             Grade = "incomplete",
             Paid = hasPaid
         };
     db.Enrollments.Add(newEnrollment);
 }
Ejemplo n.º 7
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.º 8
0
 private void BuildAttendanceData(Course course, Student thisStudent)
 {
     for (int i = 0; i < course.AttendingDays; i++)
     {
         // Adds attendance rows for every day needed in the attendance table
         var newAttendance = new Attendance
             {
                 CourseID = course.CourseID,
                 StudentID = thisStudent.StudentID,
                 AttendanceDay = i + 1,
                 Present = true
             };
         db.Attendance.Add(newAttendance);
     }
 }
Ejemplo n.º 9
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);
        }
Ejemplo n.º 10
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");
        }
Ejemplo n.º 11
0
        public ActionResult ApplyUsingDetails(Course idGetter)
        {
            // try to join course
            Course course = db.Courses.Find(idGetter.CourseID);
            if (course.Approved && !course.Completed)
            {
                Student thisStudent = db.Students.FirstOrDefault(o => o.UserName == User.Identity.Name);

                Enrollment nullIfStudentDoesNotHaveThisCourse =
                    db.Enrollments.FirstOrDefault(
                        p => p.StudentID == thisStudent.StudentID && p.CourseID == course.CourseID);

                if (nullIfStudentDoesNotHaveThisCourse == null)
                {
                    if (course.Enrollments.Count < course.AttendanceCap)
                    {
                        CreateEnrollmentAttendanceAndNotificationData(course, thisStudent);
                        TempData["tempMessage"] =
                            "You have successfully enrolled in this Course. (Please note that the below details are default values until your Instructor updates them)";
                        return RedirectToAction("StudentDetails", "Attendance", new { id = course.CourseID });
                    }

                    return RedirectToAction("Message", new { message = "This course is full." });
                }

                return RedirectToAction("Message", new { message = "This student is already enrolled in this course." });
            }

            return RedirectToAction(
                "Message",
                new
                    {
                        message =
                            "Course is not ready to be joined, it has not been approved by an Administrator or has already concluded."
                    });
        }