public void Cancel_appointment_when_appointment_can_be_canceled() { Appointment appointmentForCancel = this.GetAppointmentForCancelSuccesfull(); appointmentRepository.GetById(appointmentForCancel.Id).Returns(appointmentForCancel); bool isCanceled = appointmentService.CancelAppointment(appointmentForCancel.Id); Assert.True(isCanceled); Assert.True(appointmentForCancel.IsCanceled); }
public void CancelAppointment_SetsOrderToCancelled() { var order = _fixture.Create <Order>(); order.IsCancelled = false; _context.Order.Add(order); _context.SaveChanges(); _sut.CancelAppointment(order.PatientId, order.Id); _context.Order.First().IsCancelled.Should().BeTrue(); }
public IActionResult CancelAppointment(Guid appointmentId) { if (!IsValidAuthenticationRole("Patient")) { return(StatusCode(403)); } try { bool isCanceled = _appointmentService.CancelAppointment(appointmentId); if (isCanceled) { return(Ok()); } else { return(BadRequest()); } } catch (NotFoundEntityException) { return(StatusCode(404)); } catch (Exception) { return(StatusCode(500)); } }
public ActionResult CancelAppointment(CancelAppointmentViewModel model) { try { var authInfo = (AuthInfo)Session["auth_info"]; if (authInfo == null) { return(Json(new KeyValueResult(false, "Your session has expired. Please signin again."), JsonRequestBehavior.AllowGet)); } var data = new CancelAppoinmentModel { AppointmentId = model.AppointmentId, DoctorName = model.DoctorName, ClinicName = authInfo.CurrentSelectedClinic.ClinicName, ClinicPhone = authInfo.CurrentSelectedClinic.Phone, Patient = new PatientCreateAppointmentModel { FirstName = model.PatientFirstName, LastName = model.PatientLastName, Phone = model.PatientPhone, Email = model.PatientEmail }, ExpectedStartDateTime = model.ExpectedStartDateTime, }; _appointmentService.CancelAppointment(data); return(Json(new KeyValueResult(true, "Welio appointment successfully canceled."), JsonRequestBehavior.AllowGet)); } catch (ApiException ex) { return(Json(new KeyValueResult(false, ex.Message), JsonRequestBehavior.AllowGet)); } }
public Response Cancel(int id) { Response response = new Response() { Success = true }; try { appointmentService.CancelAppointment(id); } catch (RecordNotFoundException exc) { response.Success = false; response.ErrorCode = ((int)ErrorResponse.RecordNotFound).ToString(); response.ErrorMessage = exc.Message; } catch (Exception exc) { response.Success = false; response.ErrorCode = ((int)ErrorResponse.ServerError).ToString(); response.ErrorMessage = exc.Message; } return(response); }
public IActionResult CancelAppointment(int appointmentId) { if (_appointmentService.CancelAppointment(appointmentId) == null) { return(NotFound()); } return(Ok()); }
public async Task <ActionResult> CancelAppointment(int id) { var identity = HttpContext.User.Identity as ClaimsIdentity; IEnumerable <Claim> claims = identity.Claims; var userId = claims.First(c => c.Type == ClaimTypes.NameIdentifier).Value; await _appointmentService.CancelAppointment(id, Int32.Parse(userId)); return(NoContent()); }
public async Task CancelAppointment([FromBody] CancelAppointmentRequestViewModel request) { var currentUser = await _userService.GetUserByName(HttpContext.User.Identity.Name); var model = Mapper.Map <CancelAppointmentRequestDto>(request); model.UserId = currentUser.Id.ToString(); await _appointmentService.CancelAppointment(model); }
public async Task <IActionResult> Cancel([FromBody] int bookingID) { var cancelled = await _appointmentService.CancelAppointment(bookingID); if (!cancelled) { return(BadRequest(new { error = "Cancel appointment failed" })); } return(Ok()); }
public IHttpActionResult Cancel([FromBody] int appointmentId) { var result = _appointmentService.CancelAppointment(appointmentId, User.Identity.GetUserId()); if (!result.Succeeded) { return(BadRequest(result.ErrorMessage)); } return(Ok()); }
public IActionResult CancelAppointment(Guid appointmentId) { try { bool isCanceled = _appointmentService.CancelAppointment(appointmentId); if (isCanceled) { return(Ok()); } else { return(BadRequest()); } } catch (NotFoundEntityException e) { return(StatusCode(404)); } catch (InternalServerErrorException e) { return(StatusCode(500)); } }
public async Task <IActionResult> CancelAppointment([FromRoute] int patientId, [FromBody] DateTime appointmentDate) { await _appointmentService.CancelAppointment(patientId, appointmentDate); return(Ok()); }
/// <summary> /// Cancels the appointment /// </summary> /// <param name="appointment">appointment</param> /// <returns></returns> public Response <AppointmentModel> CancelAppointment(AppointmentModel appointment) { return(appointmentService.CancelAppointment(appointment)); }