Exemplo n.º 1
0
        public ActionResult RiderDetails(decimal lat1, decimal lat2, decimal lng1, decimal lng2)
        {
            BookRideViewModel model = new BookRideViewModel
            {
                PLat = lat1,
                Plng = lng1,
                DLat = lat2,
                Dlng = lat2
            };

            return(View(model));
        }
Exemplo n.º 2
0
 public ActionResult RiderDetails(BookRideViewModel model)
 {
     if (!ModelState.IsValid)
     {
         return(View(model));
     }
     try
     {
         //create rider
         Rider rider = new Rider(new User.NameFormat {
             FirstName = model.RiderFirstName, LastName = model.RidierLastName
         }, new User.ContactNumberFormat(model.CountryCode, model.CompanyCode, model.Number));
         //Book Ride
         var ride = rider.BookRide(new Ride.RideBookingDetails
         {
             Destination = new Location {
                 Latitude = model.DLat, Longitude = model.Dlng
             },
             PickUpLocation = new Location {
                 Latitude = model.PLat, Longitude = model.Plng
             },
             VehicleType = new VehicleType(model.VehicleType)
         });
         //Add Promo
         if (model.PromoCode != null || model.PromoCode == String.Empty)
         {
             ride.AddPromo(PromoCode.GetPromoCode(model.PromoCode));
         }
         return(RedirectToAction("BookRide"));
     }
     catch (UniqueKeyViolationException ex)
     {
         ModelState.AddModelError(String.Empty, ex.Message);
         return(View(model));
     }
     catch (UnsuccessfullProcessException)
     {
         ModelState.AddModelError(String.Empty, "Seems like no driver is available near the pick-up point.");
         return(View(model));
     }
     catch (Exception ex)
     {
         return(RedirectToAction("ErrorPage", "Error", ex));
     }
 }