public override async Task OnInitializing() { Items = await RidesService.GetUserRides(refresher : Refresh); await base.OnInitializing(); if (Items != null && Items.Length > 0) { var Item = Items[0]; await MapView.Add(new Map.Annotation { Title = Item.From, Location = new Zebble.Services.GeoLocation(Item.FromStation.Latitude, Item.FromStation.Longitude) }); await MapView.Add(new Map.Annotation { Title = Item.To, Location = new Zebble.Services.GeoLocation(Item.ToStation.Latitude, Item.ToStation.Longitude) }); MapView.Center = new Zebble.Services.GeoLocation(((Item.ToStation.Latitude + Item.FromStation.Latitude) / 2), ((Item.ToStation.Longitude + Item.FromStation.Longitude) / 2)); } else { await MapView.Add(new Map.Annotation { Title = GlobalSettings.City, Location = new Zebble.Services.GeoLocation(GlobalSettings.EventLatitude, GlobalSettings.EventLongitude) }); } }
public override async Task OnInitializing() { bookRequest = Nav.Param <Booking>("Booking"); if (bookRequest == null) { var userRides = await RidesService.GetUserRides(); if (userRides != null) { var ride = userRides.Where(rec => rec.Start > LocalTime.Now).OrderBy(rec => rec.Start).FirstOrDefault(); if (ride != null) { bookRequest = new Booking { BikeId = ride.BikeId, DueDate = ride.Start.AddMinutes(ride.Duration), EventId = ride.EventId, FromStation = ride.FromStation, Id = ride.Id, RegistrationDate = ride.Start, RideType = ride.RideType, ToStation = ride.ToStation }; } } } if (bookRequest == null) { await Alert.Show("Alert", "There is no available ride"); return; } await base.OnInitializing(); BookModule.From = new CustomPin { Label = bookRequest.FromStation.Name }; BookModule.To = new CustomPin { Label = bookRequest.ToStation.Name }; timerControl = new Timer(CounterFunc, null, 1, 1000); }