Exemple #1
0
        public IActionResult Index()
        {
            double maxPrice = 0;
            double minPrice = 0;
            IEnumerable <Hamper>   activeHampers    = _hamperRepo.GetActiveHampers();
            IEnumerable <Category> activeCategories = _categoryRepo.Query(c => c.Active == true);


            if (activeHampers.Count() == 0)
            {
                return(RedirectToAction("Create"));
            }

            maxPrice = activeHampers.OrderByDescending(h => h.Price).ElementAt(0).Price;
            minPrice = activeHampers.OrderBy(h => h.Price).ElementAt(0).Price;


            HamperIndexViewModel vm = new HamperIndexViewModel();

            vm.Hampers    = activeHampers;
            vm.Categories = activeCategories;
            vm.MaxPrice   = maxPrice;
            vm.MinPrice   = minPrice;

            return(View(vm));
        }
Exemple #2
0
        public JsonResult GetAllHampers()
        {
            IEnumerable <Hamper> activeHampers = _hamperRepo.GetActiveHampers();

            foreach (var item in activeHampers)
            {
                item.Category = _categoryRepo.GetSingle(c => c.CategoryId == item.CategoryId);
            }

            return(Json(activeHampers));
        }
Exemple #3
0
        // GET: /<controller>/
        public IActionResult Index()
        {
            IEnumerable <Category> categories = _categoryRepo.Query(c => c.Active == true);
            IEnumerable <Hamper>   hampers    = _hamperRepo.GetActiveHampers();
            IEnumerable <Gift>     gifts      = _giftRepo.GetAll();

            AdminIndexViewModel vm = new AdminIndexViewModel()
            {
                Categories = categories,
                Hampers    = hampers,
                Gifts      = gifts
            };

            return(View(vm));
        }