Esempio n. 1
0
        public static EntityListViewModel GetLastViewdItems(string protoName)
        {
            var result = new EntityListViewModel();
            HttpCookie cookie = HttpContext.Current.Request.Cookies[CookiePrefix + protoName];
            var ids = new List<long>();

            if (cookie != null)
            {
                ids = cookie.Value.Split(',').Select(item => Convert.ToInt64(item)).ToList();
            }

            switch (protoName)
            {
                case "hotels":
                    var hotels = (from id in ids where Meridian.Default.hotelsStore.Exists(id) select Meridian.Default.hotelsStore.Get(id)).ToList();
                    result = EntityMapper.ToHotelsListViewModel(hotels, 1, EntitiesCount);
                    break;
                case "resorts":
                    var resorts = (from id in ids where Meridian.Default.resortsStore.Exists(id) select Meridian.Default.resortsStore.Get(id)).ToList();
                    result = EntityMapper.ToResortsListViewModel(resorts, 1, EntitiesCount);
                    break;
            }

            return result;
        }
Esempio n. 2
0
        public ActionResult RecomendedList(string protoName, long id, int count = 4)
        {
            var model = new EntityListViewModel();

            switch (protoName)
            {
                case "health_factors":
                    var resorts = meridian.resortsStore.All()
                            .Where(item => item.health_factors_items.Select(h => h.id).Contains(id) && item.is_recomended && item.is_published)
                            .ToList();
                    model = EntityMapper.ToResortsListViewModel(resorts, 1, count);
                    ViewBag.ShowAll = Url.Action("resortsearch", "home", new {HealthFactorId = id});
                    break;
                case "cure_profiles":
                    resorts = meridian.resortsStore.All()
                            .Where(item => item.cure_profiles_items.Select(h => h.id).Contains(id) && item.is_recomended && item.is_published)
                            .ToList();
                    model = EntityMapper.ToResortsListViewModel(resorts, 1, count);
                    ViewBag.ShowAll = Url.Action("resortsearch", "home", new {CureProfileId = id});
                    break;
                case "deseases":
                    var hotels = meridian.hotelsStore.All()
                            .Where(item => item.deseases_items.Select(h => h.id).Contains(id) && item.is_recomended && item.is_published)
                            .ToList();
                    model = EntityMapper.ToHotelsListViewModel(hotels, 1, count);
                    ViewBag.ShowAll = Url.Action("hotelsearch", "home", new { DeseaseId = id });
                    break;
                case "treatment_options":
                    hotels = meridian.hotelsStore.All()
                            .Where(item => item.treatment_options_items.Select(h => h.id).Contains(id) && item.is_recomended && item.is_published)
                            .ToList();
                    model = EntityMapper.ToHotelsListViewModel(hotels, 1, count);
                    ViewBag.ShowAll = Url.Action("hotelsearch", "home", new { TreatmentId = id });
                    break;
            }

            return View(model);
        }