public HttpResponseMessage FixAppointment(HttpRequestMessage request, [FromBody]BookAppointment appointmentModel) { return GetHttpResponse(request, () => { HttpResponseMessage response = null; var user = User.Identity.Name; _appointmentService=new AppointmentClient(); var appointment = _appointmentService.BookAppointment(user,appointmentModel.AppointmentDate,appointmentModel.Doctor); response = request.CreateResponse<Appointment>(HttpStatusCode.OK, appointment); return response; }); }
public async Task <IActionResult> Book([FromBody] BookingRecordRequest bookingRecordRequest) { var bookingRecord = new BookingRecord { contact = new Contact { Name = bookingRecordRequest.contact.Name, Phone = bookingRecordRequest.contact.Phone, Email = bookingRecordRequest.contact.Email }, TimeSlotID = bookingRecordRequest.TimeSlotID, Date = bookingRecordRequest.Date, Description = bookingRecordRequest.Description }; var booked = await _appointmentService.BookAppointment(bookingRecord); if (!booked) { return(BadRequest(new { error = "Book appointment failed" })); } return(Ok(_mapper.Map <BookingResponse>(bookingRecord))); }
public ActionResult Book(BookFormViewModel viewModel) { if (ModelState.IsValid) { var result = _appointmentService.BookAppointment(viewModel.Subject, viewModel.DateTime, viewModel.TimeSpan, User.Identity.GetUserId(), viewModel.Type.Id, viewModel.Availability.Id); if (result.Succeeded) { return(RedirectToAction("Index")); } ModelState.AddModelError("Appointment", result.ErrorMessage); } var types = _appointmentService.GetAppointmentTypes(); var availability = _userAvailabilityService.GetAvailability(viewModel.Availability.Id); viewModel.Types = Mapper.Map <IEnumerable <AppointmentTypeViewModel> >(types); viewModel.SelectableStartTimes = _appointmentService.GetAppointmentStartTimes(availability); viewModel.SelectableEndTimes = _appointmentService.GetAppointmentEndTimes(availability); return(View("BookForm", viewModel)); }
public async Task <IActionResult> BookAppointment([FromRoute] int patientId, [FromBody] DateTime appointmentDate) { await _appointmentService.BookAppointment(patientId, appointmentDate); return(Accepted()); }