public TripPossiblePlace Create(TripPossiblePlace toCreate) { _db.TripPossiblePlaces.Add(toCreate); _db.SaveChanges(); return(toCreate); }
public static TripPossiblePlaceViewModel ToViewModel(this TripPossiblePlace possiblePlace) { var vm = new TripPossiblePlaceViewModel() { TripId = possiblePlace.TripId, PlaceId = possiblePlace.PlaceId, PlaceType = possiblePlace.PlaceType, Distance = possiblePlace.Distance, Place = possiblePlace.Place?.ToViewModel() }; return(vm); }
protected void AddPossiblePlaceToTrip(Trip trip, Reading reading, TripPossiblePlaceType type) { var ownerId = trip.Car.OwnerId; var possiblePlaces = _placeService.GetPlacesNearby(reading.Latitude, reading.Longitude, 150, ownerId); foreach (var place in possiblePlaces) { var possiblePlace = new TripPossiblePlace() { Trip = trip, TripId = trip.TripId, Place = place, PlaceType = type, Distance = Convert.ToDecimal(GeographyUtils.CalculateDistanceBetweenLocations( reading.Latitude, reading.Longitude, place.Latitude, place.Longitude)), Active = true }; _tripPossiblePlaceService.Create(possiblePlace); } _logger.Debug($"Added possible {type.ToString()} to trip {trip.TripId}"); }