public SuperTripViewModel ConvertToSuperTripViewModel(Orders order) { SuperTripViewModel superTripVM = new SuperTripViewModel(); SuperTrip supertrip = order.SuperTrip; superTripVM.SupertripId = supertrip.id; superTripVM.DepartureStation = StationProvider.GetStationNameById(supertrip.id_departure_station); superTripVM.DepartureDate = supertrip.departure_date; superTripVM.ArrivalStation = StationProvider.GetStationNameById(supertrip.id_arrival_station); superTripVM.ArrivalDate = supertrip.arrival_date; superTripVM.IsDirect = IsDirect(supertrip); superTripVM.Price = Convert.ToDouble(supertrip.price); superTripVM.Quantity = order.quantity; return(superTripVM); }
public IHttpActionResult GetSuperTripDetail(int supertripId) { List <TripViewModel> tripVMs = new List <TripViewModel>(); List <Trip> trips = (from o in db.SuperTrip where o.id == supertripId select o.Trip).First().ToList <Trip>(); foreach (Trip trip in trips) { TripViewModel tripVM = new TripViewModel(); tripVM.DepartureStation = StationProvider.GetStationNameById(trip.id_departure_station); tripVM.DepartureDate = trip.departure_date; tripVM.ArrivalStation = StationProvider.GetStationNameById(trip.id_arrival_station); tripVM.ArrivalDate = trip.arrival_date; tripVMs.Add(tripVM); } return(Ok(tripVMs)); }
public List <SuperTripViewModel> ConvertToSuperTripViewModel(List <SuperTrip> supertrips) { List <SuperTripViewModel> superTripVMs = new List <SuperTripViewModel>(); foreach (SuperTrip supertrip in supertrips) { SuperTripViewModel superTripVM = new SuperTripViewModel(); superTripVM.SupertripId = supertrip.id; superTripVM.DepartureStation = StationProvider.GetStationNameById(supertrip.id_departure_station); superTripVM.DepartureDate = supertrip.departure_date; superTripVM.ArrivalStation = StationProvider.GetStationNameById(supertrip.id_arrival_station); superTripVM.ArrivalDate = supertrip.arrival_date; superTripVM.IsDirect = IsDirect(supertrip); superTripVM.Price = Convert.ToDouble(supertrip.price); superTripVM.Quantity = 1; superTripVMs.Add(superTripVM); } return(superTripVMs); }