Esempio n. 1
0
        public ActionResult ViewFavouriteTours()
        {
            using (var db = new WishoianContext())
            {
                var restult = new List<TourPlanDetailViewModel>();
                var tourPlan = db.TourPlans.Take(5).ToList().OrderByDescending(t => t.Viewed);
                foreach (var item in tourPlan)
                {
                    var viewModel = new TourPlanDetailViewModel
                    {
                        Tour = new TourDetailViewModel() { Tour = item.Tour, SpecialTourPlan = item },
                        TourSchedules = item.Tour.TourSchedules.OrderBy(s => s.IndexDay).ToList(),
                        TourPlan = item
                    };
                    restult.Add(viewModel);
                }
                // Set up our ViewModel

                return PartialView(restult);
            }
        }
Esempio n. 2
0
        public ViewResult ViewTourDetail(Guid tourPlanId)
        {
            using (var db = new WishoianContext())
            {
                var tourPlan = db.TourPlans.Find(tourPlanId);
                if (tourPlan != null)
                {
                    // Set up our ViewModel
                    var viewModel = new TourPlanDetailViewModel
                    {
                        Tour = new TourDetailViewModel() { Tour = tourPlan.Tour, SpecialTourPlan = tourPlan },
                        TourSchedules = tourPlan.Tour.TourSchedules.OrderBy(s => s.IndexDay).ToList(),
                        TourPlan = tourPlan
                    };

                    // Update View
                    db.Entry(tourPlan).State = EntityState.Modified;
                    if (tourPlan.Viewed == null)
                        tourPlan.Viewed = 1;
                    else

                        tourPlan.Viewed += 1;
                    db.SaveChanges();
                    return View(viewModel);

                }
                return View();
            }
        }
Esempio n. 3
0
        public ViewResult SearchTour(TourSearchViewModel search)
        {
            var lst = new List<TourPlanDetailViewModel>();
            using (var db = new WishoianContext())
            {
                var tourPlan = db.TourPlans.Where(t =>
                    t.Tour.TourType.TypeName == search.TourTypeName
                    && ((search.OpenDate == null) || t.OpenDate >= search.OpenDate)
                    && (search.StartLocationId == t.Tour.StartLocationId && (search.EndLocationId == null || search.EndLocationId.Value == t.Tour.EndLocationId))
                    ).ToList();

                foreach (var item in tourPlan)
                {
                    // Set up our ViewModel
                    var viewModel = new TourPlanDetailViewModel
                    {
                        Tour = new TourDetailViewModel() { Tour = item.Tour, SpecialTourPlan = item },
                        TourSchedules = item.Tour.TourSchedules.OrderBy(s => s.IndexDay).ToList(),
                        TourPlan = item
                    };
                    lst.Add(viewModel);
                }

                return View(lst);
            }
        }