private void PrepareStudentCounselingRequestModel(AppointmentByStudentModel model) { // Add the corresponding counseler to the view model. var student = Student; var @class = _classRepository.GetById(student.ClassId); var counseler = CounselerRepository.GetById(@class.CounselerId); model.Counseler = Mapper.Map <CounselerModel>(counseler); }
public ActionResult AppointmentByStudent() { DateTime tommorow = DateTime.Now.AddDays(1); var model = new AppointmentByStudentModel { // Default appointment date is tomorrow 10:00. DateTimeString = new DateTime(tommorow.Year, tommorow.Month, tommorow.Day, 10, 0, 0).ToString("dd-MM-yyyy HH:mm") }; PrepareStudentCounselingRequestModel(model); return(View(model)); }
public ActionResult AppointmentByStudent(AppointmentByStudentModel model, string id) { // A student wishes to make an appointment with their counseler. if (ModelState.IsValid) { // Get the logged in student and counseler of the class the student is in. var currUser = (UserModel)System.Web.HttpContext.Current.Session["user"]; ViewBag.id = id; var curStudent = repository.Students.FirstOrDefault(x => x.PIN == id); Teacher teacher = repository.Teachers.FirstOrDefault(x => x.PIN == currUser.Login); if (teacher != null && curStudent != null) { // Create the appointment for the student and couseler. var appointment = new Appointment { PIN = teacher.PIN, StudentID = curStudent.StudentID, DateTime = model.DateTime, Location = model.Location }; repository.AddAppointment(appointment); // Send the appointment request mail. /*var mail = new AppointmentMail * { * Counseler = counseler, * Student = student, * DateTime = appointment.DateTime, * Location = appointment.Location, * AcceptUrl = FullUrl("AppointmentResponse", new { id }), * FromCounseler = false * }; * * _mailHelper.SendAppointmentMail(mail);*/ return(RedirectToAction("Details", "Appointment", new { id })); } } PrepareStudentCounselingRequestModel(model); return(View(model)); }
public ActionResult AppointmentByStudent(AppointmentByStudentModel model) { // A student wishes to make an appointment with their counseler. if (ModelState.IsValid) { // Get the logged in student and counseler of the class the student is in. var student = Student; var @class = _classRepository.GetById(student.ClassId); var counseler = CounselerRepository.GetById(@class.CounselerId); if (counseler != null && student != null) { // Create the appointment for the student and couseler. var appointment = new Appointment { CounselerId = counseler.Id, StudentId = student.Id, DateTime = model.DateTime, Location = model.Location }; int id = _appointmentRepository.Add(appointment); // Send the appointment request mail. var mail = new AppointmentMail { Counseler = counseler, Student = student, DateTime = appointment.DateTime, Location = appointment.Location, AcceptUrl = FullUrl("AppointmentResponse", new { id }), FromCounseler = false }; _mailHelper.SendAppointmentMail(mail); return(RedirectToAction("Details", "Appointment", new { id })); } } PrepareStudentCounselingRequestModel(model); return(View(model)); }