TopShelfCustomer/TopShelfCustomer/ViewModels/ShopViewModel.cs
/// <summary>
/// InitializeStore:
///
/// Sets all bindable properties for the ShopView.
/// Also calls the API to fetch the store/product data.
/// </summary>


Sets all bindable properties for the ShopView.
Also calls the API to fetch the store/product data.
Sets all bindable properties for the ShopView . Also calls the API to fetch the store / product data .
private async Task InitializeStore () {
                ApiHelper api = new ApiHelper();
                var productsList = await api.GetAsync<List<Product>>( "Store/GetAllProducts" );     
                if ( UserContainer.CurrentUser.StoreName == "" ) {       
                    Debug.WriteLine( "Error: could not find default store" );
                    App.SetNewPage<ChooseStoreView>();
                }
                SelectedStoreName = UserContainer.CurrentUser.StoreName;        
                foreach ( Product product in productsList ) {       
                    ShopItem item = new ShopItem { Item = product, Quantity = 0, Price = product.Price };
                    ShopInventory.Add( item );
                    UserContainer.UserCart.Items.Add( item );
                }
            }
private async Task InitializeStore ( ) { ApiHelper api = new ApiHelper ( ) ; var productsList = await api . GetAsync < List < Product > > ( " " ) ; if ( UserContainer . CurrentUser . StoreName == " " ) { Debug . WriteLine ( " " ) ; App . SetNewPage < ChooseStoreView > ( ) ; } SelectedStoreName = UserContainer . CurrentUser . StoreName ; foreach ( Product product in productsList ) { ShopItem item = new ShopItem { Item = product , Quantity = 0 , Price = product . Price } ; ShopInventory . Add ( item ) ; UserContainer . UserCart . Items . Add ( item ) ; } }
InitializeStore:
InitializeStore :
//FIXME: correct endpoint //Check if the User has a default Store //Set the Header "Store Name" label //Add all products in the returned list to the bindable list