public ActionResult AvailableAppointments(BookAppointmentViewModel app) { //TODO... check why the date is not if (ModelState.IsValid) { var sTime = app.StartTime; var eTime = app.EndTime; string id = User.Identity.GetUserId(); var appointment = new Appointment() { Date = app.Date, StartTime = sTime, EndTime = eTime, PatientId = app.PatientId, UserId = id }; var created = _appointmentRepository.AddAppointment(appointment); if (created) { return(RedirectToAction("Index", new { date = app.Date })); } return(HttpNotFound()); } return(RedirectToAction("AvailableAppointments", new { id = app.PatientId, date = app.Date })); }
public async Task <bool> BookAppointment(BookingRecord bookingRecord) { var removeTimePortion = new TimeSpan(0, 0, 0); bookingRecord.Date = bookingRecord.Date.Date + removeTimePortion; var timeSlotavailability = await _appointmentRepository.VerifyTimeSlotAvailable(bookingRecord); if (!timeSlotavailability) { // TODO: log time slot unavailable return(false); } var existingContact = await _contactRepository.CheckDuplicate(bookingRecord.contact); var contactID = existingContact.ID != 0 ? existingContact.ID : await _contactRepository.AddContact(bookingRecord.contact); var added = await _appointmentRepository.AddAppointment(bookingRecord, contactID); // TODO: log added successful return(added); }
public void UpdateExistentAppointment() { var appointment = new Appointment { AppointmentName = "appointment", AppointmentTime = DateTime.Now }; var appointmentDetail = new AppointmentDetail { Appointment = appointment, Organiser = "testOrganiser", Attendees = new List <string> { "attendee1", "attendee2" } }; _repository.AddAppointment(appointmentDetail); appointment.AppointmentName = "updatedAppointment"; var updateResponse = _repository.UpdateApointment(appointment); var updatedAppointment = _repository.GetAppointmentById(appointment.Id); Assert.IsTrue(updatedAppointment.AppointmentName == "updatedAppointment"); }
public async Task <ActionResult> AddAppointment(DateTime date, string serviceName) { var service = await _serviceRepository.GetByNameAsync(serviceName); if (service == null) { return(BadRequest("El servicio no existe!")); } Appointment appointment = new Appointment() { Date = date, ServiceId = service.Id, Status = Enums.AppointmentStatus.available }; _appointmentRepository.AddAppointment(appointment); if (await _appointmentRepository.SaveAllAsync()) { return(Ok()); } return(BadRequest("Error al agregar el turno")); }
public IActionResult AddAppointment(Appointment appointment) { if (ModelState.IsValid) { _Appointments.AddAppointment(appointment); return(View("AppointmentRequestSent")); } return(View(appointment)); }
public IActionResult AddAppointment([FromBody] AppointmentDTO appointment) { if (ModelState.IsValid) { string newAppointment = repository.AddAppointment(appointment); return(new ObjectResult(newAppointment)); } else { return(BadRequest("Request not valid!")); } }
public async Task <IActionResult> CreateAppointment(AppointmentCreate model) { try { await _repository.AddAppointment(model); return(NoContent()); } catch (Exception ex) { return(BadRequest()); } }
public IActionResult CreateAppointment([FromBody] Appointment appointment) { if (appointment == null) { return(BadRequest()); } if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var createdDoctor = _appointmentRepository.AddAppointment(appointment); return(Created("appointment", createdDoctor)); }
public IActionResult AddAppointment(Appointment appointment) { try { if (appointment == null) { return(BadRequest("Data is null.")); } if (!ModelState.IsValid) { Errors errors = ErrorsHelper.GetErrors(ModelState); return(BadRequest(errors)); } Appointment addedAppointment = appointmentRepository.AddAppointment(appointment); return(StatusCode(StatusCodes.Status201Created, addedAppointment)); } catch (Exception ex) { Errors errors = ErrorsHelper.GetErrors(ex); return(StatusCode(StatusCodes.Status500InternalServerError, errors)); } }
public HttpResponseMessage AddAppointment(Appointment appointment) { try { if (appointment == null) { return(Request.CreateResponse(HttpStatusCode.BadRequest, "Data is null.")); } if (!ModelState.IsValid) { Errors errors = ErrorsHelper.GetErrors(ModelState); return(Request.CreateResponse(HttpStatusCode.BadRequest, errors)); } Appointment addedAppointment = appointmentRepository.AddAppointment(appointment); return(Request.CreateResponse(HttpStatusCode.Created, addedAppointment)); } catch (Exception ex) { Errors errors = ErrorsHelper.GetErrors(ex); return(Request.CreateResponse(HttpStatusCode.InternalServerError, errors)); } }
public void AddAppointmentAndThenGetReturnsSame() { var appointment = new Appointment { AppointmentName = "test", AppointmentTime = DateTime.Now, }; var appointmentDetail = new AppointmentDetail { Appointment = appointment, Organiser = "testo", Attendees = new List <string> { "test1", "test2" } }; _repository.AddAppointment(appointmentDetail); var savedAppointment = _repository.GetAllAppointments().First(); Assert.AreEqual(appointment, savedAppointment); }
public void DeleteExistingAppointment() { var appointment = new Appointment { AppointmentName = "test", AppointmentTime = DateTime.Now }; var appointmentDetail = new AppointmentDetail { Appointment = appointment, Organiser = "organiser", Attendees = new List <string> { "attendee1", "attendee2" } }; _repository.AddAppointment(appointmentDetail); var deleteResponse = _repository.DeleteAppointment(appointment); Assert.IsTrue(deleteResponse); Assert.IsTrue(!_repository.GetAllAppointments().Any()); }
public async Task <Appointment> AddAppointment(NewAppointment newAppointment) { return(await _appointmentRepository.AddAppointment(newAppointment)); }
public JsonResult AddAppointment(AppointmentViewModel appointment) { return(Json(appointmentRepository.AddAppointment(appointment))); }
public async Task <Appointment> AddAppointment(RegisterAppointmentModel model) { return(await _appointmentRepository.AddAppointment(model)); }
public void AddAppointment(int patientId, int doctorId, DateTime dateTime, string reason) { _appointmentRepository.AddAppointment(patientId, doctorId, dateTime, reason); }
public int PostAddAppointment([FromBody] Appointment appointment) { return(repository.AddAppointment(appointment)); }
public Response <AppointmentViewModel> AddAppointment(AppointmentViewModel appointment) { return(appointmentRepository.AddAppointment(appointment)); }