Beispiel #1
0
        public ActionResult RequestQAHelp(QAHelpRequestViewModel qaHelpRequest)
        {
            ViewBag.Message = "Request QA Help From Tutor";
            GetUIDropdownLists();

            if (ModelState.IsValid)
            {
                _teacherRepository.RequestQATime(new QAHelpRequest
                {
                    QAHelpRequestId = qaHelpRequest.QAHelpRequestId,
                    TeacherId       = qaHelpRequest.TeacherId,
                    Description     = qaHelpRequest.Description,
                    StartTime       = DateTime.Now,
                    EndTime         = DateTime.Now,
                    StudentId       = qaHelpRequest.StudentId,
                    StudentRole     = qaHelpRequest.StudentRole,
                    SubjectId       = qaHelpRequest.SubjectId,
                    DateCreated     = DateTime.Now
                });
                var student = _teacherRepository.GetStudentById(qaHelpRequest.StudentId);
                var teacher = _teacherRepository.GetTeacherById(qaHelpRequest.TeacherId);
                var subject = _teacherRepository.GetSubjectById(qaHelpRequest.SubjectId);
                _emailService.SendEmail(new TicketMasterEmailMessage {
                    EmailFrom = ConfigurationManager.AppSettings["BusinessEmail"], Subject = $"Request Help from {student.StudentLastName } in subject: { subject.SubjectName } and Role {qaHelpRequest.StudentRole}", EmailTo = new List <string> {
                        teacher.EmailAddress, student.EmailAddress
                    }, EmailMessage = $"Request Help from {student.StudentLastName } in subject: { subject.SubjectName } and Role {qaHelpRequest.StudentRole} with the suggested Student request Help times with Start Time at: {qaHelpRequest.StartTime.ToString("dd-MM-yyyy HH:mm")} and End Time {qaHelpRequest.EndTime.ToString("dd-MM-yyyy HH:mm")}. Please await the teacher to confirm by email whether this will be a good time for them. \r\nKindest Regards\r\nMartinLayooInc Team."
                });
                return(View("_SuccessfullCreation", qaHelpRequest));
            }
            return(View());
        }
        public ActionResult ManageSubject(SubjectViewModel subjectViewModel)
        {
            GetUIDropdownLists();
            if (subjectViewModel.Select != null)
            {
                ModelState.Clear();
                if (subjectViewModel.SubjectId < 1)
                {
                    ModelState.AddModelError("SubjectId", "SubjectId is required");
                }
                if (ModelState.IsValid)
                {
                    var subject = _repositoryServices.GetSubjectById(subjectViewModel.SubjectId);
                    subjectViewModel = (SubjectViewModel)Mapper.Map(subject, typeof(Subject), typeof(SubjectViewModel));

                    ModelState.Clear();
                }
                return(View("ManageSubject", subjectViewModel));
            }
            if (subjectViewModel.Delete != null)
            {
                ModelState.Clear();
                if (subjectViewModel.SubjectId < 1)
                {
                    ModelState.AddModelError("SubjectId", "SubjectId is required");
                }
                if (ModelState.IsValid)
                {
                    var subject = _repositoryServices.GetSubjectById(subjectViewModel.SubjectId);
                    _repositoryServices.DeleteSubject(subject);
                    return(View("SuccessfullCreation"));
                }
                return(View("ManageSubject", subjectViewModel));
            }
            var subjectModel = (Subject)Mapper.Map(subjectViewModel, typeof(SubjectViewModel), typeof(Subject));

            if (subjectViewModel.SubjectName != null)
            {
                _repositoryServices.ManageSubject(subjectModel);
                return(View("SuccessfullCreation"));
            }
            return(View("ManageSubject", subjectViewModel));
        }
Beispiel #3
0
        public ActionResult BookTeacherHelpTime(TeacherCalendarUpdateViewModel bookingTimeViewModel)
        {
            ViewBag.Message = "Book Teacher Time.";
            GetUIDropdownLists();
            if (ModelState.IsValid)
            {
                if (bookingTimeViewModel.Delete != null)
                {
                    var teacherCalendar = _teacherRepository.GetTeacherCalendarByBookingId(bookingTimeViewModel.CalendarBookingId);
                    _teacherRepository.DeleteTeacherCalendarByBooking(teacherCalendar);
                    return(View("_SuccessfullCreation"));
                }
                Teacher teacher = _teacherRepository.GetTeacherByName(User.Identity.Name);
                Student student = _teacherRepository.GetStudentByName(bookingTimeViewModel.StudentFullName);
                Subject subject = _teacherRepository.GetSubjectById(bookingTimeViewModel.SubjectId);
                foreach (var bookingTime in bookingTimeViewModel.BookingTimes)
                {
                    _teacherRepository.SaveOrUpdateBooking(teacher, student, subject, new BookingTime {
                        BookingTimeId = bookingTime.BookingTimeId, StartTime = DateTime.Parse(bookingTime.StartTime, new DateTimeFormatInfo {
                            FullDateTimePattern = "yyyy-MM-dd HH:mm"
                        }), EndTime = DateTime.Parse(bookingTime.EndTime, new DateTimeFormatInfo {
                            FullDateTimePattern = "yyyy-MM-dd HH:mm"
                        })
                    }, bookingTimeViewModel.Description);
                }
                var emailService = new EmailServices.EmailService(ConfigurationManager.AppSettings["smtpServer"], ConfigurationManager.AppSettings["smtpServerUser"], ConfigurationManager.AppSettings["smtpServerPassword"]);

                var emailMessage = new System.Net.Mail.MailMessage();

                var fileInfo = new FileInfo(Server.MapPath("~/Infrastructure/EmailTemplates/TeacherBookingTime.html"));
                var html     = fileInfo.OpenText().ReadToEnd();
                html.Replace("{TeacherName}", teacher.EmailAddress);
                html.Replace("{StudentName}", student.EmailAddress);
                html.Replace("{SubjectName}", subject.SubjectName);
                html.Replace("{StartTime}", bookingTimeViewModel.BookingTimes[0].StartTime);
                html.Replace("{EndTime}", bookingTimeViewModel.BookingTimes[0].EndTime);
                emailService.EmailType = EmailType.Html;
                //emailService.SendEmail(new TicketMasterEmailMessage {EmailFrom= student.EmailAddress, EmailMessage = html,EmailTo = new List<string> {student.EmailAddress}, Subject = "Teacher Assistant's Booking Time Schedule"});
                var message = new TicketMasterEmailMessage {
                    EmailFrom = ConfigurationManager.AppSettings["BusinessEmail"], EmailTo = new List <string> {
                        student.EmailAddress
                    }, Subject = "Teacher Assistant's Booking Time Schedule", EmailMessage = html
                };
                emailService.SendEmail(message);
                return(View("_SuccessfullCreation"));
            }
            return(View("BookTeacherHelpTime", bookingTimeViewModel));
        }
Beispiel #4
0
        public ActionResult BookTeacherHelpTime()
        {
            ViewBag.Message = "Book Teacher Time.";
            GetUIDropdownLists();

            var calendars = _teacherRepository.GetTeacherCalendar();
            var calendarBookingViewModels = new List <CalendarBookingViewModel>();

            if (calendars != null)
            {
                var classRooms = _teacherRepository.GetClassrooms();

                var calendarsLeftJoin = from cal in calendars
                                        join cls in classRooms on
                                        cal.CalendarBookingId equals cls.CalendarId into res
                                        from q in res.DefaultIfEmpty()
                                        select new
                {
                    ClassroomId   = q == null ? null : q.ClassroomId,
                    SubjectId     = cal.SubjectId,
                    TeacherId     = cal.TeacherId,
                    StudentId     = cal.StudentId,
                    BookingTimeId = cal.BookingTimeId
                };
                foreach (var cal in calendarsLeftJoin)
                {
                    var student     = _teacherRepository.GetStudentById(cal.StudentId);
                    var subject     = _teacherRepository.GetSubjectById(cal.SubjectId);
                    var teacher     = _teacherRepository.GetTeacherById(cal.TeacherId);
                    var bookingTime = _teacherRepository.GetBookingById(cal.BookingTimeId);

                    if (bookingTime == null)
                    {
                        continue;
                    }
                    calendarBookingViewModels.Add(new CalendarBookingViewModel {
                        Teacher = teacher, Subject = subject, Student = student, BookingTime = bookingTime, ClassroomId = cal.ClassroomId
                    });
                }
            }
            ViewBag.CalendarUiList = calendarBookingViewModels.ToArray();


            return(View("BookTeacherHelpTime"));
        }
 public ActionResult BookTeacherHelpTime(TeacherCalendarViewModel bookingTimeViewModel)
 {
     ViewBag.Message = "Book Teacher Time.";
     GetUIDropdownLists();
     if (ModelState.IsValid)
     {
         if (bookingTimeViewModel.Delete != null)
         {
             var teacherCalendar = _teacherRepository.GetTeacherCalendarByBookingId(bookingTimeViewModel.CalendarBookingId);
             _teacherRepository.DeleteTeacherCalendarByBooking(teacherCalendar);
             return(View("SuccssessfullCreation"));
         }
         Teacher teacher = _teacherRepository.GetTeacherByName(User.Identity.Name);
         Student student = _teacherRepository.GetStudentByName(bookingTimeViewModel.StudentFullName);
         Subject subject = _teacherRepository.GetSubjectById(bookingTimeViewModel.SubjectId);
         foreach (var bookingTime in bookingTimeViewModel.BookingTimes)
         {
             _teacherRepository.SaveOrUpdateBooking(teacher, student, subject, bookingTime, bookingTimeViewModel.Description);
         }
         return(View("SucssessfullCreation"));
     }
     return(View("BookTeacherHelpTime", bookingTimeViewModel));
 }