public static Trip ConvertToTrip(TripDto t) { var posixTime = DateTime.SpecifyKind(new DateTime(1970, 1, 1, 0, 0, 0), DateTimeKind.Utc); DateTime departure = posixTime.AddMilliseconds(t.DepartureTime); return(new Trip(t.Id, t.Landmark, t.CompanyName, departure, t.Price, t.AvailablePlaces)); }
public static Response CreateGetTripsResponse(List <Trip> trips) { Response response = new Response() { Type = Response.Types.ResponseType.Ok }; trips.ForEach(el => { double departure = el.DepartureTime.Subtract(new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc)).TotalMilliseconds; TripDto trip = new TripDto() { Id = el.Id, Landmark = el.Landmark, CompanyName = el.CompanyName, DepartureTime = departure, Price = el.Price, AvailablePlaces = el.AvailablePlaces }; response.Trips.Add(trip); }); return(response); }