public HttpResponseMessage Post([FromBody] CompanionDTO.ReservationDTO reservation)
        {
            // saving the new order to the database
            Reservation newReservation = CompanionDTOMappers.ReservationExtensions.FromReservationDTO(reservation);

            // send a reservation creation request to the backend booking service.
            // TODO: 1 - Remove the code to the backend WCF service
            string confirmationCode = CreateReservationOnBackendSystem(newReservation);

            //string confirmationCode = "";

            newReservation.ConfirmationCode = confirmationCode;
            Reservations.Add(newReservation);
            Reservations.Save();


            // creating the response, with three key features:
            // 1. the newly saved entity
            // 2. 201 Created status code
            // 3. Location header with the location of the new resource
            var response = Request.CreateResponse(HttpStatusCode.Created, newReservation);

            response.Headers.Location = new Uri(Request.RequestUri, newReservation.ReservationId.ToString());
            return(response);
        }
示例#2
0
        public HttpResponseMessage Post([FromBody] CompanionDTO.ReservationDTO reservation)
        {
            // saving the new order to the database
            Reservation newReservation = CompanionDTOMappers.ReservationExtensions.FromReservationDTO(reservation);

            // send a reservation creation request to the backend booking service.
            string confirmationCode = CreateReservationOnBackendSystem(newReservation);

            newReservation.ConfirmationCode = confirmationCode;
            Reservations.Add(newReservation);
            Reservations.Save();

            Configuration.Services.GetTraceWriter().Info(Request, "ReservationsController", "New reservation was created: {0}", confirmationCode);

            // creating the response, with three key features:
            // 1. the newly saved entity
            // 2. 201 Created status code
            // 3. Location header with the location of the new resource
            var response = Request.CreateResponse(HttpStatusCode.Created, newReservation);

            response.Headers.Location = new Uri(Request.RequestUri, newReservation.ReservationId.ToString());
            return(response);
        }