コード例 #1
0
        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);
        }
コード例 #2
0
        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();
        }
コード例 #3
0
        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));
            }
        }
コード例 #4
0
        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));
            }
        }
コード例 #5
0
        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);
        }
コード例 #6
0
        public IActionResult CancelAppointment(int appointmentId)
        {
            if (_appointmentService.CancelAppointment(appointmentId) == null)
            {
                return(NotFound());
            }

            return(Ok());
        }
コード例 #7
0
        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());
        }
コード例 #8
0
        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);
        }
コード例 #9
0
        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());
        }
コード例 #10
0
        public IHttpActionResult Cancel([FromBody] int appointmentId)
        {
            var result = _appointmentService.CancelAppointment(appointmentId, User.Identity.GetUserId());

            if (!result.Succeeded)
            {
                return(BadRequest(result.ErrorMessage));
            }

            return(Ok());
        }
コード例 #11
0
 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));
     }
 }
コード例 #12
0
        public async Task <IActionResult> CancelAppointment([FromRoute] int patientId, [FromBody] DateTime appointmentDate)
        {
            await _appointmentService.CancelAppointment(patientId, appointmentDate);

            return(Ok());
        }
コード例 #13
0
 /// <summary>
 /// Cancels the appointment
 /// </summary>
 /// <param name="appointment">appointment</param>
 /// <returns></returns>
 public Response <AppointmentModel> CancelAppointment(AppointmentModel appointment)
 {
     return(appointmentService.CancelAppointment(appointment));
 }