Exemplo n.º 1
0
        public ActionResult Index(string id, string priceOrder)
        {
            if (string.IsNullOrEmpty(id))
                id = _userInfo.LastSelectedCategory;
            else
                _userInfo.LastSelectedCategory = id;

            var dataProvider = new DataProvider();
            var selectors = dataProvider.GetSelectors();

            ViewBag.CategorySelectors = selectors[0];
            ViewBag.EventSelectors = selectors[1];
            var bouquetes = dataProvider.GetBouquetsByCategory(id);
            if (!string.IsNullOrEmpty(priceOrder))
            {
                if (priceOrder.ToLower() == "lacne")
                    bouquetes = bouquetes.OrderBy(_ => _.Sizes.Min(size => size.Price)).ToList();
                else if (priceOrder.ToLower() == "drahe")
                    bouquetes = bouquetes.OrderByDescending(_ => _.Sizes.Max(size => size.Price)).ToList();
            }
            ViewBag.Bouquetes = bouquetes;
            ViewBag.CurrentCategory = id;
            ViewBag.CurrentOrder = priceOrder;

            return View();
        }