void FixCity()
        {
            if (SelectedCity == null)
            {
                CreateAndShowError("Please select a City of Service");
                return;
            }

            var request = new CreateBookingRequest() { CityId = SelectedCity.Id };
            request.CreatorId = CurrentBooking.CreatorId;
            request.PrimaryPassengerId = CurrentBooking.PrimaryPassengerId;
            BookingsService.BeginCreateBooking(request, CreateAsyncCallback(ar => BookingsService.EndCreateBooking(ar),
                result =>
                {
                    if (result.HasErrors)
                    {
                        ShowErrors(result.Errors);
                        return;
                    }

                    CurrentBooking = result.Booking;
                    StopExpirationTimer();

                    ChangeView(eMainView.GetQuote, eSubView.TypeOfJourney);
                }), null);
        }
Ejemplo n.º 2
0
        public BookingResponse CreateBooking(CreateBookingRequest request)
        {
            try
            {
                using (var db = new LomsContext())
                {
                    var pickUpEndpoint = new BookingEndpoint();
                    var dropOffEndpoint = new BookingEndpoint();
                    db.BookingEndpoints.ApplyChanges(pickUpEndpoint);
                    db.BookingEndpoints.ApplyChanges(dropOffEndpoint);
                    db.SaveChanges();

                    var booking = new Booking()
                    {
                        Status = BookingStatus.New,
                        CityId = request.CityId,
                        CreatorId = request.CreatorId,
                        PrimaryPassengerId = request.PrimaryPassengerId,
                        PickUpEndpointId = pickUpEndpoint.Id,
                        DropOffEndpointId = dropOffEndpoint.Id
                    };

                    db.Bookings.ApplyChanges(booking);
                    db.SaveChanges();

                    booking = GetBooking(db, booking.Id);
                    return new BookingResponse { Booking = booking };
                }
            }
            catch (Exception ex)
            {
                var response = new BookingResponse();
                response.AddError("Response", ex.ToString());
                return response;
            }
        }