示例#1
0
        public IViewComponentResult Invoke(DrinkCategory cat)
        {
            var isMobileTablet = _device.Type == DeviceType.Mobile || _device.Type == DeviceType.Tablet;
            var isOpen         = DateTime.Now.TimeOfDay > TimeSpan.FromHours(8) && DateTime.Now.TimeOfDay < TimeSpan.FromHours(17);
            var drinks         = cat.Id == 0 ? _drinkRepository.PreferredDrinks.ToList() : cat.Id == -1 ? _drinkRepository.NewDrinks.ToList(): _drinkRepository.DrinksByCategory(cat.Id).ToList();
            var notifyPopup    = _notifyPopupRepository.GetActiveNotifyPopup();

            ViewData["IsOpen"]         = isOpen;
            ViewData["NotifyPopup"]    = notifyPopup;
            ViewData["isMobileTablet"] = isMobileTablet;
            ViewData["cat"]            = cat;

            return(View(drinks));
        }