// GET: Trips public ActionResult Index() { using (var db = new TripsOfferDbContext()) { var trips = db.Trips.ToList(); var viewModel = trips.Select(trip => Mapper.Map <TripViewModel>(trip)) .ToList(); return(View(viewModel)); } }
public GetTripsResponse GetTrips(GetTripsRequest request) { using (var db = new TripsOfferDbContext()) { var trips = db.Trips.Where(trip => trip.NumberOfDays >= request.MinNumberOfDays && trip.NumberOfDays <= request.MaxNumberOfDays) .ToList(); var response = new GetTripsResponse() { Succees = true, Trips = trips.Select(trip => Mapper.Map <TripDesc>(trip)) .ToList() }; return(response); } }
public GetToursResponse GetTours(GetToursRequest request) { using (var db = new TripsOfferDbContext()) { db.Database.Log = s => System.Diagnostics.Debug.WriteLine(s); var trips = db.Trips.Where(tour => request.TripIDs.Contains(tour.ID)) .SelectMany(trip => trip.Tours) .ToList(); var response = new GetToursResponse() { Succees = true, Tours = trips.Select(tour => Mapper.Map <TourDesc>(tour)) .ToList() }; return(response); } }
public ActionResult GetOffers(string categoryId, int limit) { Thread.Sleep(1000); using (TripsOfferDbContext db = new TripsOfferDbContext()) { var viewModel = new SpecialOffersViewModel() { Offers = db.Trips.SelectMany(t => t.Tours, (trip, tour) => new OfferViewModel() { Name = trip.Name, Cost = tour.Cost, StartTime = tour.StartTime, }) .Take(limit) .ToList() }; return(PartialView("SpecialOffers", viewModel)); } }