void DisplayInMap(BusStopDataModel stops) { foreach (var stop in stops.Stops) { try { var position = new Position(stop.StopLat, stop.StopLon); var pin = new Pin() { Type = PinType.SavedPin, Position = position, Label = stop.StopDesc }; locationsMap.Pins.Add(pin); } catch (NullReferenceException nre) { } catch (Exception e) { } } }
public void UpdateBusStopDataModel(BusStopDataModel busStopDataModel) { if (busStopDataModel == null) { return; } using (var session = DocumentStoreHolder.Store.OpenSession()) { var id = session.Query <BusStopDataModel>().FirstOrDefault()?.Id; if (string.IsNullOrEmpty(id)) { Save(busStopDataModel); return; } var bsdm = session.Load <BusStopDataModel>(id); bsdm.Day = busStopDataModel.Day; bsdm.LastUpdate = busStopDataModel.LastUpdate; bsdm.Stops = busStopDataModel.Stops; session.SaveChanges(); } }
public static void SetChooseBusStopModelCollection(BusStopDataModel busStopDataModel, List <GroupedJoinedModel> groupedJoinedTrips) { busStopDataModel.Stops = new ObservableCollection <StopModel>(busStopDataModel.Stops.Select(stop => { var busLineNamesStringBuilder = new StringBuilder(); var destinationsStringBuilder = new StringBuilder(); foreach (var groupedJoinedModel in groupedJoinedTrips) { foreach (var joinedTripModel in groupedJoinedModel.JoinedTripModels) { var joinedTripModelList = joinedTripModel.JoinedTrips.Where(x => x.Stops.Any(y => y.StopId == stop.StopId)).ToList(); foreach (var item in joinedTripModelList) { if (!destinationsStringBuilder.ToString().Contains(item.BusLineName)) { busLineNamesStringBuilder.Append(item.BusLineName + ", "); } if (!destinationsStringBuilder.ToString().Contains(item.DestinationStopName)) { destinationsStringBuilder.Append(item.DestinationStopName + ", "); } } } } var busLines = busLineNamesStringBuilder.ToString(); if (busLines.Length > 0) { busLines = busLines.Substring(0, busLines.Length - 2); } var destinations = destinationsStringBuilder.ToString(); if (destinations.Length > 0) { destinations = destinations.Substring(0, destinations.Length - 2); //removes extra ", " at the end of the string } stop.BusLineNames = busLines; stop.DestinationHeadsigns = destinations; return(stop); })); DocumentStoreRepository.UpdateBusStopDataModel(busStopDataModel); }