public UpdateBookingResponse UpdateBooking(UpdateBookingRequest request)
        {
            AdministrationServiceDAO adminDAO = new AdministrationServiceDAO();
            bool result = adminDAO.UpdateBooking(request.booking);

            return(new UpdateBookingResponse(result));
        }
Exemplo n.º 2
0
        public async Task HandleWithValidUpdateRequestCallSaveAsExpectedResultAsync()
        {
            // Arrange
            var bookingModel = new Booking {
                Id = 299536, DropLocation = "Chennai, Chrompet"
            };

            var config = new MapperConfiguration(m => { m.CreateMap <Entities.Booking, Booking>(); m.CreateMap <Booking, Entities.Booking>(); });
            var mapper = new Mapper(config);

            var bookingEntity = new Entities.Booking {
                Id = 299536, DropLocation = "Chennai, Chrompet"
            };

            repository = new Mock <IRepository>();
            repository.Setup(m => m.Get <Entities.Booking>(It.IsAny <int>())).Returns(bookingEntity);
            repository.Setup(m => m.Update <Entities.Booking>(It.IsAny <Entities.Booking>())).Returns(bookingEntity);

            underTest = new UpdateBooking(repository.Object, mapper);
            request   = new UpdateBookingRequest(bookingModel);

            // Act
            CancellationToken cancellationToken;
            var result = await underTest.Handle(request, cancellationToken);

            // Assert
            Assert.NotNull(result);
            Assert.Equal(bookingModel.Id, result.Id);
            Assert.Equal(bookingModel.DropLocation, result.DropLocation);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Updates Booking status information.Newly created booking has status `reserved`. In this status BeMyGuest inventory is not yet deducted.Inventory is locked after changing status of the booking from `reserved` to `waiting` (`confirm` action).When the booking is first created, it is marked as `reserved`. Inventories aren't touched yet. Once the partner decides to confirm the said booking, this is the only time the inventory will be impacted. The booking status will be updated from `reserved` to `waiting`.5 days after the booking date all booking with status `waiting` will be marked `expired`.There's 3rd extra action you may invoke in this method : `resend`. If `confirmationEmailSentAt` value is not null then the confirmation email copy sent o partner will be sent again and the timestamp value of this field will be updated.In response Booking object is returned, for example        {          "data": {              "uuid": "c53cbc74-1efa-58bb-afef-750afc52cd75",              "totalAmount": "123.98",              "currencyCode": "SGD",              "currencyUuid": "cd15153e-dfd1-5039-8aa3-115bec58e86e",              "totalAmountRequestCurrency": "369.46",              "requestCurrencyCode": "MYR",              "requestCurrencyUuid": "e98aaf89-ae5a-5c11-859a-b36f2c8e13c7",              "createdAt": "2015-12-21 19:53:23",              "updatedAt": "2015-12-21 19:53:23",              "arrivalDate": "2016-02-21",              "salutation": "Mr.",              "firstName": "test",              "lastName": "test",              "email": "*****@*****.**",              "phone": "123456789",              "guests": 2,              "children": 0,              "partnerReference": "test93828",              "confirmationEmailSentAt": null,              "confirmationEmailFiles": [],              "status": "reserved",              "productTypeTitle": "14% OFF for Family: E-Ticket to Universal Studios Singapore",              "productTypeTitleTranslated": "14% OFF for Family: E-Ticket to Universal Studios Singapore",              "productTypeUuid": "9b967f1a-89c2-5083-a758-e359deb2af9b"            }        }### Parameters+ uuid (required,string) - UUID of booking+ status (string) - Status "confirm" or "cancel"
        /// </summary>
        /// <param name="status">Required parameter: New status of the booking, one of [confirm, cancel, resend]</param>
        /// <param name="uuid">Required parameter: UUID of booking</param>
        /// <param name="data">Optional parameter: TODO: type parameter description here</param>
        /// <return>Returns the UpdateBookingStatusResponse response from the API call</return>
        public async Task <UpdateBookingStatusResponse> UpdateBookingStatusAsync(
            string status,
            string uuid,
            UpdateBookingRequest data = null)
        {
            //the base uri for api requestss
            string _baseUri = Configuration.BaseUri;

            //prepare query string for API call
            StringBuilder _queryBuilder = new StringBuilder(_baseUri);

            _queryBuilder.Append("/v1/bookings/{uuid}/{status}");

            //process optional template parameters
            APIHelper.AppendUrlWithTemplateParameters(_queryBuilder, new Dictionary <string, object>()
            {
                { "status", status },
                { "uuid", uuid }
            });

            //validate and preprocess url
            string _queryUrl = APIHelper.CleanUrl(_queryBuilder);

            //append request with appropriate headers and parameters
            var _headers = new Dictionary <string, string>()
            {
                { "user-agent", "BeMyGuest.SDK.v1" },
                { "accept", "application/json" },
                { "content-type", "application/json; charset=utf-8" }
            };

            _headers.Add("X-Authorization", Configuration.XAuthorization);

            //append body params
            var _body = APIHelper.JsonSerialize(data);

            //prepare the API call request to fetch the response
            HttpRequest _request = ClientInstance.PutBody(_queryUrl, _headers, _body);

            //invoke request and get response
            HttpStringResponse _response = (HttpStringResponse)await ClientInstance.ExecuteAsStringAsync(_request);

            HttpContext _context = new HttpContext(_request, _response);

            //handle errors defined at the API level
            base.ValidateResponse(_response, _context);

            try
            {
                return(APIHelper.JsonDeserialize <UpdateBookingStatusResponse>(_response.Body));
            }
            catch (Exception ex)
            {
                throw new APIException("Failed to parse the response: " + ex.Message, _context);
            }
        }
        private bool OrderDoesNotExist(UpdateBookingRequest request, ref PdrValidationResult result)
        {
            if (_context.Order.Any(x => x.Id.Equals(request.Id)))
            {
                return(false);
            }


            result.PassedValidation = false;
            result.Errors.Add("Order does not exist");
            return(true);
        }
Exemplo n.º 5
0
        public Booking Put(UpdateBookingRequest request)
        {
            var bookingCtr  = new BookingCtr();
            var bookingData = new Booking
            {
                ID        = request.ID,
                StartDate = request.StartDate,
                EndDate   = request.EndDate,
            };

            bookingCtr.UpdateBooking(bookingData);
            return(bookingData);
        }
Exemplo n.º 6
0
        public UpdateBookingResponse UpdateBooking(UpdateBookingRequest request)
        {
            AdministrationServiceDAO adminDAO = new AdministrationServiceDAO();
            bool result = adminDAO.UpdateBooking(request.booking);

            if (result)
            {
                return(new UpdateBookingResponse(result));
            }
            else
            {
                ThrowNotFoundException(request.booking.id);
                return(null);
            }
        }
        public PdrValidationResult ValidateRequest(UpdateBookingRequest request)
        {
            var result = new PdrValidationResult(true);

            if (MissingRequiredFields(request, ref result))
            {
                return(result);
            }

            if (OrderDoesNotExist(request, ref result))
            {
                return(result);
            }

            return(result);
        }
Exemplo n.º 8
0
 public IActionResult UpdateBooking(UpdateBookingRequest request)
 {
     try
     {
         var result = _bookingService.UpdateBooking(request);
         return(Ok(result.Booking));
     }
     catch (ArgumentException ex)
     {
         return(BadRequest(ex.Message));
     }
     catch (Exception ex)
     {
         return(StatusCode(500, ex));
     }
 }
        private bool MissingRequiredFields(UpdateBookingRequest request, ref PdrValidationResult result)
        {
            var errors = new List <string>();

            if (request.Id == Guid.Empty)
            {
                errors.Add("Must be a valid Id");
            }

            if (errors.Any())
            {
                result.PassedValidation = false;
                result.Errors.AddRange(errors);
                return(true);
            }

            return(false);
        }
Exemplo n.º 10
0
        public UpdateBookingResponse UpdateBooking(UpdateBookingRequest request)
        {
            //Get order
            var validationResult = _updateBookingRequestValidator.ValidateRequest(request);

            if (!validationResult.PassedValidation)
            {
                throw new ArgumentException(validationResult.Errors.First());
            }

            var order = _context.Order.First(x => x.Id.Equals(request.Id));

            //Update
            order.StartTime   = request.StartTime;
            order.EndTime     = request.EndTime;
            order.PatientId   = request.PatientId;
            order.Patient     = _context.Patient.FirstOrDefault(x => x.Id == request.PatientId);
            order.DoctorId    = request.DoctorId;
            order.Doctor      = _context.Doctor.FirstOrDefault(x => x.Id == request.DoctorId);
            order.SurgeryType = (int)_context.Patient.FirstOrDefault(x => x.Id == request.PatientId).Clinic.SurgeryType;
            order.Status      = request.Status;

            //Save
            _context.SaveChanges();

            return(new UpdateBookingResponse
            {
                Booking = new Booking
                {
                    StartTime = order.StartTime,
                    EndTime = order.EndTime,
                    PatientId = order.PatientId,
                    DoctorId = order.DoctorId,
                    SurgeryType = order.SurgeryType,
                    Status = (BookingStatus)order.Status
                }
            });
        }
Exemplo n.º 11
0
        public async Task <IActionResult> Update(int bookingId, UpdateBookingRequest request)
        {
            var response = await Mediator.Send(Mapper.Map(request, new UpdateBookingCommand(bookingId)));

            return(Ok(response));
        }