public ActionResult Appointment(Appointment appointment, Patient patient, String email, String password) { if (_accountService.ValidateLogin(email, password) && _accountService.GetUser(email).Role == "Patient") { if (_patientService.IsAppointmentTaken(_accountService.GetUser(email).UserId, appointment.Date)) { return Json("Appointment already taken", JsonRequestBehavior.AllowGet); } patient.UserId = _accountService.GetUser(email).UserId; return Json(_patientService.RegisterAppointment(appointment, patient), JsonRequestBehavior.AllowGet); } else { return Json("Unauthorized Access", JsonRequestBehavior.AllowGet); } }
public Appointment RegisterAppointment(Appointment model, Patient patient) { if (_appointmentRepository.IsAppointmentAvailable(model.DoctorId, model.Date)) { model.PatientId = _patientRepository.AddPatient(patient); model.TakenAt = DateTime.Now; model.Uid = Guid.NewGuid().ToString(); model.Serial = _appointmentRepository.GenerateSerial(model.DoctorId, model.Date) + 1; _appointmentRepository.Add(model); return model; } else { var waiting = new Waiting(); waiting.TakenAt = DateTime.Now; waiting.Name = patient.Name; waiting.UserId = patient.UserId; waiting.DoctorId = model.DoctorId; waiting.Date = model.Date; _waitingRepository.Add(waiting); } return null; }
public ActionResult AddAppointment(Appointment appointment, Patient patient) { appointment.DoctorId = _doctorService.GetDoctorId(User.Identity.Name); _patientService.RegisterAppointment(appointment, patient); return RedirectToAction("Appointments", "Doctor", _doctorService.GetAppointments(User.Identity.Name)); }