public async Task Initialize(bool forceRefresh = false)
        {
            await sema.WaitAsync();

            if (this.AllCoffees.Any() && !forceRefresh)
            {
                return;
            }

            this.AllCoffees.Clear();
            this.FavoriteCoffees.Clear();

            var favorites = await favoriteService.GetFavorites();

            var coffees = (await coffeeService.GetAll()).OrderBy(c => c.Name);

            foreach (var favorite in favorites)
            {
                this.FavoriteCoffees.Add(coffees.Single(c => c.Id == favorite));
            }

            foreach (var coffee in coffees)
            {
                this.AllCoffees.Add(coffee);
            }

            sema.Release();
        }
Exemple #2
0
        public ActionResult Index()
        {
            List <CoffeeView> allCoffee = coffeeService.GetAll().Select(CoffeeMapper.Map).ToList();

            ViewBag.Countries   = SelectListHelper.GetCountries(countryService);
            ViewBag.CoffeeSorts = SelectListHelper.GetEnum <CoffeeSortBll>();

            return(View(allCoffee));
        }