public TripDetail FromBolt(TaxiRequest order, Bolt.Models.Responses.PriceEstimateResponse response, DistanceResponse distance) { var price = order.CarType == CarType.Business ? response.Data.SearchCategories.Single(x => x.Name.Equals("Comfort")) : response.Data.SearchCategories.Single(x => x.Name.Equals("Bolt")); var minCost = int.Parse(price.PricePrediction.Trim('₴').Split('–').First()); var maxCost = int.Parse(price.PricePrediction.Trim('₴').Split('–').Last()); var avgCost = (minCost + maxCost) / 2; var detail = new TripDetail { CarType = order.CarType, TaxiService = TaxiService.Bolt, Details = new TripData { Price = new Price { MinPrice = minCost, MaxPrice = maxCost, Cost = avgCost, SurgeMultiplier = price.SurgeMultiplier }, Distance = distance.Distance, Duration = distance.Duration, PickupTime = price.PickupTime, Seats = 4 } }; return(detail); }
public TripDetail FromTaxi838(TaxiRequest order, Taxi838.Models.Responses.PriceEstimateResponse response, DistanceResponse distance) { var cost = int.Parse(response.Price.Split(' ').First()); var detail = new TripDetail { CarType = order.CarType, TaxiService = TaxiService.Taxi838, Details = new TripData { Price = new Price { Cost = cost, MinPrice = cost - new Random().Next(10), MaxPrice = cost + new Random().Next(30) }, Distance = distance.Distance, Duration = distance.Duration, Seats = order.CarType == CarType.Minibus ? 8 : 4 } }; return(detail); }
public TripDetail FromUber(TaxiRequest order, Uber.Models.Responses.PriceEstimateResponse priceEstimate, Uber.Models.Responses.TimeEstimateResponse timeEstimate) { var price = order.CarType == CarType.Business ? priceEstimate.Prices.Single(x => x.DisplayName.Equals("UberSelect")) : priceEstimate.Prices.Single(x => x.DisplayName.Equals("UberX")); var time = order.CarType == CarType.Business ? timeEstimate.Times.Single(x => x.DisplayName.Equals("UberSelect")) : timeEstimate.Times.Single(x => x.DisplayName.Equals("UberX")); var detail = new TripDetail { CarType = order.CarType, TaxiService = TaxiService.Uber, Details = new TripData { Price = new Price { Cost = (int)((price.LowEstimate + price.HighEstimate) / 2), MinPrice = (int?)price.LowEstimate, MaxPrice = (int?)price.HighEstimate }, Distance = price.Distance, Duration = (int)price.Duration, Seats = 4, PickupTime = (int?)time.Estimate } }; return(detail); }
private async void myTap(object sender, TappedRoutedEventArgs e) { Pushpin p = (Pushpin)sender; MessageDialog dialog = new MessageDialog("Taxi request from " + client[int.Parse(p.Text)], "Dispatch Taxi?"); dialog.Commands.Add(new UICommand("Dispatch", async(UICommandInvokeHandler) => { TaxiRequest item = cb[int.Parse(p.Text)].DataContext as TaxiRequest; await UpdateChecked(item); pushpinLayer.Children.Remove(p); message("Dispatch"); } )); //First Command Ends here // Second command starts here dialog.Commands.Add(new UICommand("Don't Dispatch!", async(UICommandInvokeHandler) => { TaxiRequest item = cb[int.Parse(p.Text)].DataContext as TaxiRequest; await UpdateChecked(item); pushpinLayer.Children.Remove(p); message("Don't"); } )); dialog.Commands.Add(new UICommand("Cancel")); await dialog.ShowAsync(); await RefreshTodoItems(); }
public bool Validate(TaxiRequest request) { if (request?.Origin == null || request.Destination == null) { return(false); } return(true); }
private async Task UpdateChecked(TaxiRequest item) { // This code takes a freshly completed TodoItem and updates the database. When the MobileService // responds, the item is removed from the list items.Remove(item); ListItems.Focus(Windows.UI.Xaml.FocusState.Unfocused); await itemsTable.DeleteAsync(item); }
public DistanceRequest CreateDistanceRequest(TaxiRequest request) { var distance = new DistanceRequest { Origin = new Location(request.Origin.Latitude, request.Origin.Longitude), Destination = new Location(request.Destination.Latitude, request.Destination.Longitude) }; return(distance); }
private async void reqhere_Click(object sender, RoutedEventArgs e) { if (reqhere.Label == "Request") { string time = DateTime.Now.TimeOfDay.ToString(); string rtime = reqtime.Time.ToString(); if (reqtime.Time < DateTime.Now.TimeOfDay) { MessageBox("", "Invalid Time Chosen!"); } else { try { reqhere.Icon = new SymbolIcon(Symbol.Cancel); reqhere.Label = "Cancel Request"; latt = MyMap.Center.Position.Latitude; lon = MyMap.Center.Position.Longitude; var items = new TaxiRequest { Username = validuser, Lattitude = latt.ToString(), Longitude = lon.ToString(), Time = time, RTime = rtime }; var messagedialog = new MessageDialog("Time of Request: " + reqtime.Time, "Please Confirm your Taxi booking, " + validuser); //First command starts messagedialog.Commands.Add(new UICommand("Yes", async(UICommandInvokeHandler) => { await InsertTodoItem(items); progressBar.Visibility = Windows.UI.Xaml.Visibility.Visible; positionTextBlock.Text = "Your request is on the way..."; timer.Start(); } )); //First Command Ends here // Second command starts here messagedialog.Commands.Add(new UICommand("No")); await messagedialog.ShowAsync(); } catch (Exception ex) { MessageBox("Error. Try again!", ""); } } } else { progressBar.Visibility = Windows.UI.Xaml.Visibility.Collapsed; reqhere.Icon = new SymbolIcon(Symbol.ReShare); reqhere.Label = "Request"; timer.Stop(); maxTime = 31; positionTextBlock.Text = "Your Request has been cancelled!"; } }
public Uber.Models.Requests.PriceEstimateRequest CreateUberRequest(TaxiRequest request) { var uber = new Uber.Models.Requests.PriceEstimateRequest { StartLatitude = request.Origin.Latitude, StartLongitude = request.Origin.Longitude, EndLatitude = request.Destination.Latitude, EndLongitude = request.Destination.Longitude }; return(uber); }
public Bolt.Models.Requests.PriceEstimateRequest CreateBoltRequest(TaxiRequest request) { var bolt = new Bolt.Models.Requests.PriceEstimateRequest { StartLatitude = request.Origin.Latitude, StartLongitude = request.Origin.Longitude, EndLatitude = request.Destination.Latitude, EndLongitude = request.Destination.Longitude }; return(bolt); }
public async Task <IActionResult> Estimate([FromQuery] TaxiRequest order) { if (_validator.Validate(order) == false) { return(BadRequest()); } var price = await _taxi.EstimateOrderAsync(order); var vm = _mapper.Map(price); return(Ok(vm)); }
public Taxi838.Models.Requests.PriceEstimateRequest CreateTaxi838Request(TaxiRequest request) { Taxi838.Models.Requests.CarType carType; switch (request.CarType) { case Domain.Models.CarType.Variant: carType = Taxi838.Models.Requests.CarType.Universal; break; case Domain.Models.CarType.Minibus: carType = Taxi838.Models.Requests.CarType.Minibus; break; default: carType = Taxi838.Models.Requests.CarType.Standart; break; } var taxi838 = new Taxi838.Models.Requests.PriceEstimateRequest { Points = new Dictionary <string, TaxiAggregator.Taxi838.Models.Requests.Point> { { "0", new TaxiAggregator.Taxi838.Models.Requests.Point(request.Origin.Latitude, request.Origin.Longitude) }, { "1", new TaxiAggregator.Taxi838.Models.Requests.Point(request.Destination.Latitude, request.Destination.Longitude) } }, CarType = carType }; return(taxi838); }
public Uklon.Models.Requests.PriceEstimateRequestV2 CreateUklonRequest(TaxiRequest request) { Uklon.Models.Requests.CarType carType; switch (request.CarType) { case Domain.Models.CarType.Variant: carType = Uklon.Models.Requests.CarType.Wagon; break; case Domain.Models.CarType.Economy: carType = Uklon.Models.Requests.CarType.Econom; break; case Domain.Models.CarType.Business: carType = Uklon.Models.Requests.CarType.Premium; break; case Domain.Models.CarType.Minibus: carType = Uklon.Models.Requests.CarType.Minivan; break; default: carType = Uklon.Models.Requests.CarType.Standard; break; } var uklon = new Uklon.Models.Requests.PriceEstimateRequestV2 { Route = new Uklon.Models.Requests.Route { RoutePoints = new List <Uklon.Models.Requests.Point>() }, CarType = carType.ToString() }; return(uklon); }
public TripDetail FromUklon(TaxiRequest order, Uklon.Models.Responses.PriceEstimateResponse response, DistanceResponse distance) { var detail = new TripDetail { CarType = order.CarType, TaxiService = TaxiService.Uklon, Details = new TripData { Price = new Price { Cost = response.Cost, MinPrice = response.LowCost, MaxPrice = response.HighCost, SurgeMultiplier = response.CostMultiplier }, Distance = response.Distance, Duration = distance.Duration, Seats = order.CarType == CarType.Minibus ? 8 : 4 } }; return(detail); }
public bool ValidateOrder(TaxiRequest request) { // TODO: add validation logic here return(true); }
public Uklon.Models.Requests.NearestAddressRequest CreateNearestAddressRequest(TaxiRequest request, bool fromOrigin = true) { var uklon = new Uklon.Models.Requests.NearestAddressRequest { Latitude = fromOrigin ? request.Origin.Latitude : request.Destination.Latitude, Longitude = fromOrigin ? request.Origin.Longitude : request.Destination.Longitude }; return(uklon); }
//Azure Start private async Task InsertTodoItem(TaxiRequest student) { // This code inserts a new TodoItem into the database. When the operation completes // and Mobile App backend has assigned an Id, the item is added to the CollectionView. await itemsTable.InsertAsync(student); }
public async Task <TaxiResponse> EstimateOrderAsync(TaxiRequest order) { if (!_validator.ValidateOrder(order)) { throw new InvalidOperationException("Order is not valid!"); } var response = new TaxiResponse { Origin = order.Origin, Destination = order.Destination, Details = new List <TripDetail>(4) }; //// //// //// //// //// //// GOOGLE MAPS //// //// //// //// //// //// // var distanceRequest = _factory.CreateDistanceRequest(order); var distance = await _distance.GetDistanceAsync(distanceRequest); //// //// //// //// //// //// //// UBER //// //// //// //// //// //// //// var uberRequest = _factory.CreateUberRequest(order); var uberPriceResponse = await _uber.EstimatePriceAsync(uberRequest); var uberTimeResponse = await _uber.EstimateTimeAsync(uberRequest); var uberTrip = _mapper.FromUber(order, uberPriceResponse, uberTimeResponse); response.Details.Add(uberTrip); //// //// //// //// //// //// //// UKLON //// //// //// //// //// //// /// var uklonRequest = _factory.CreateUklonRequest(order); var originAddressRequest = _factory.CreateNearestAddressRequest(order); var destinationAddressRequest = _factory.CreateNearestAddressRequest(order, false); var origin = (await _uklon.SearchNearestAddressAsync(originAddressRequest)).Addresses.Single(); var destination = (await _uklon.SearchNearestAddressAsync(destinationAddressRequest)).Addresses.Single(); uklonRequest.Route.RoutePoints.Add(new Point(origin.Address, origin.HouseNumber)); uklonRequest.Route.RoutePoints.Add(new Point(destination.Address, destination.HouseNumber)); var uklonPriceResponse = await _uklon.EstimatePriceV2Async(uklonRequest); var uklonTrip = _mapper.FromUklon(order, uklonPriceResponse, distance); response.Details.Add(uklonTrip); //// //// //// //// //// //// //// BOLT //// //// //// //// //// //// //// var boltRequest = _factory.CreateBoltRequest(order); var boltPriceResponse = await _bolt.EstimatePriceAsync(boltRequest); var boltTrip = _mapper.FromBolt(order, boltPriceResponse, distance); response.Details.Add(boltTrip); //// //// //// //// //// //// //// 838 //// //// //// //// //// //// ///// var taxi838Request = _factory.CreateTaxi838Request(order); var taxi838PriceResponse = await _taxi838.EstimatePriceAsync(taxi838Request); var taxi838Trip = _mapper.FromTaxi838(order, taxi838PriceResponse, distance); response.Details.Add(taxi838Trip); //// //// //// //// //// //// //// //// //// //// //// //// //// //// //// await _historicalData.SaveHistoricalDataAsync(response); return(response); }
public Task <HistoricalData> GetHistoricalDataForSimilarRequestAsync(TaxiRequest request) { throw new NotImplementedException(); }