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 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 ManageStudent(StudentViewModel studentViewModel) { GetUIDropdownLists(); if (studentViewModel.Select != null) { if (studentViewModel.StudentId < 1) { ModelState.AddModelError("StudentId", "StudentId is required"); } if (ModelState.IsValid) { var student = _repositoryServices.GetStudentById(studentViewModel.StudentId); studentViewModel = (StudentViewModel)Mapper.Map(student, typeof(Student), typeof(StudentViewModel)); ModelState.Clear(); } return(View("ManageStudent", studentViewModel)); } if (ModelState.IsValid) { if (studentViewModel.Delete != null) { var student = _repositoryServices.GetStudentById(studentViewModel.StudentId); _repositoryServices.DeleteStudent(student); return(View("SuccessfullCreation")); } else { var studentModel = (Student)Mapper.Map(studentViewModel, typeof(StudentViewModel), typeof(Student)); _repositoryServices.ManageStudent(studentModel); return(View("SuccessfullCreation")); } } return(View("ManageStudent", studentViewModel)); }