private void PrepareCounselerCounselingRequestModel(AppointmentByCounselerModel model) { var counseler = Counseler; // Populate the select list with all the students of the logged in counseler. model.StudentsList = SelectList(StudentRepository.GetAll().Where(s => s.Class.CounselerId == counseler.Id), s => s.Id, s => string.Format("{0} ({1})", s.GetFullName(), s.StudentNr)); }
private void PrepareCounselerCounselingRequestModel(AppointmentByCounselerModel model) { //Teacher teacher; // Populate the select list with all the students of the logged in counseler. /*model.StudentsList = SelectList(db.Students.ToList().Where(s => s.Class.Id == teacher.PIN), * s => s.Id, * s => string.Format("{0} ({1})", s.GetFullName(), s.StudentNr));*/ }
public ActionResult AppointmentByCounseler(AppointmentByCounselerModel model, string id) { if (ModelState.IsValid) { // Get the logged in counseler and the chosen student. 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 counseler and student. var appointment = new Appointment { PIN = teacher.PIN, StudentID = model.StudentId, DateTime = model.DateTime, Location = model.Location }; repository.AddAppointment(appointment); // Send the appointment mail. /*var mail = new AppointmentMail * { * Counseler = counseler, * Student = student, * DateTime = appointment.DateTime, * Location = appointment.Location, * AcceptUrl = FullUrl("AppointmentResponse", new { id }), * FromCounseler = true * }; * _mailHelper.SendAppointmentMail(mail);*/ return(RedirectToAction("Details", "Appointment", new { id })); } } PrepareCounselerCounselingRequestModel(model); return(View(model)); }
public ActionResult AppointmentByCounseler(int?studentId) { // A counseler wishes to create an appointment with their student. DateTime tommorow = DateTime.Now.AddDays(1); var model = new AppointmentByCounselerModel { // 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") }; PrepareCounselerCounselingRequestModel(model); if (studentId.HasValue) { // Prefill the student id from the querystring. model.StudentId = studentId.Value; } return(View(model)); }
public ActionResult AppointmentByCounseler(AppointmentByCounselerModel model) { if (ModelState.IsValid) { // Get the logged in counseler and the chosen student. var counseler = Counseler; var student = StudentRepository.GetById(model.StudentId); if (counseler != null && student != null) { // Create the appointment for the counseler and student. var appointment = new Appointment { CounselerId = counseler.Id, StudentId = model.StudentId, DateTime = model.DateTime, Location = model.Location }; int id = _appointmentRepository.Add(appointment); // Send the appointment mail. var mail = new AppointmentMail { Counseler = counseler, Student = student, DateTime = appointment.DateTime, Location = appointment.Location, AcceptUrl = FullUrl("AppointmentResponse", new { id }), FromCounseler = true }; _mailHelper.SendAppointmentMail(mail); return(RedirectToAction("Details", "Appointment", new { id })); } } PrepareCounselerCounselingRequestModel(model); return(View(model)); }