/// <summary> /// Converts the supplied list of <see cref="Trip"/> objects into a list of <see cref="DbTrip"/> objects. /// </summary> /// <param name="trips">The list of <see cref="Trip"/> objects to be converted.</param> /// <returns></returns> public static List <DbTrip> GetDbTrips(List <Trip> trips) { DateTime recordCreationTimeUtc = DateTime.UtcNow; var dbTrips = new List <DbTrip>(); foreach (var trip in trips) { DbTrip dbTrip = GetDbTrip(trip); dbTrip.RecordCreationTimeUtc = recordCreationTimeUtc; dbTrips.Add(dbTrip); } return(dbTrips); }
public async Task <IEnumerable <DbTrip> > Get() { var travelMock = new DbTrip() { Id = 1, Cost = 100, DepartureDate = DateTime.UtcNow.AddDays(2), ReturnDate = DateTime.UtcNow.AddDays(5), DestinationOffice = "Office1", Apartments = TravelOptionStatus.NotRequired, CarRental = TravelOptionStatus.NotRequired, TripTickets = TravelOptionStatus.NotRequired }; return(await Task.FromResult(new List <DbTrip> { travelMock })); }
/// <summary> /// Converts the supplied <see cref="Trip"/> into a <see cref="DbTrip"/>. /// </summary> /// <param name="trip">The <see cref="Trip"/> to be converted.</param> /// <returns></returns> public static DbTrip GetDbTrip(Trip trip) { DbTrip dbTrip = new DbTrip { DeviceId = trip.Device.Id.ToString(), GeotabId = trip.Id.ToString(), DriverId = trip.Driver.Id.ToString(), Distance = trip.Distance, DrivingDuration = trip.DrivingDuration, NextTripStart = trip.NextTripStart, Start = trip.Start, Stop = trip.Stop, StopDuration = trip.StopDuration }; if (trip.StopPoint != null) { dbTrip.StopPointX = trip.StopPoint.X; dbTrip.StopPointY = trip.StopPoint.Y; } return(dbTrip); }