Exemplo n.º 1
0
        private void MButtonAdd_Click(object sender, EventArgs e)
        {
            mProgressBar.Visibility = Android.Views.ViewStates.Visible;
            ShopitemViewModel newShopList = new ShopitemViewModel()
            {
                ItemName    = Name.Text,
                Quantity    = int.Parse(Quantity.Text),
                ShoplistId  = ShopListFragment.mSelectedShopList.Id,
                AddedUserId = LoginPageActivity.StaticUserClass.ID.ToString()
            };

            new Thread(new ThreadStart(async delegate
            {
                UpgradeProgress();
                var isAdded = mShopItemDataService.Add(newShopList.ToModel());

                if (isAdded)
                {
                    LoginPageActivity.mGlobalShopItem = await mShopItemDataService.GetAll();
                    this.Activity.RunOnUiThread(() => Toast.MakeText(this.Activity, "ShopList Added", ToastLength.Long).Show());
                    mProgressBar.Visibility = Android.Views.ViewStates.Invisible;
                    ReplaceFragment(new ShopItemsFragment(), "Manage ShopLists");
                }
                else
                {
                    this.Activity.RunOnUiThread(() => Toast.MakeText(this.Activity, "Failed", ToastLength.Long).Show());
                }
            })).Start();
        }
Exemplo n.º 2
0
 private void ShopItemOptions_OnComplete(object sender, OnShopItemOptionPicked e)
 {
     if (e.MenuItem == 1)
     {
         new Thread(new ThreadStart(async delegate
         {
             var isAdded = mShopItemDataService.Delete(mSelectedShopItem.Id);
             if (isAdded)
             {
                 mShopItems.Clear();
                 LoginPageActivity.mGlobalShopItem = await mShopItemDataService.GetAll();
                 LoadData();
                 this.Activity.RunOnUiThread(() => Toast.MakeText(this.Activity, "Removed", ToastLength.Long).Show());
             }
             else
             {
                 this.Activity.RunOnUiThread(() => Toast.MakeText(this.Activity, "Failed", ToastLength.Long).Show());
             }
         })).Start();
     }
     else
     {
         this.Activity.RunOnUiThread(() => Toast.MakeText(this.Activity, "Canceled", ToastLength.Long).Show());
     }
 }
Exemplo n.º 3
0
        private async void LoadData()
        {
            LoginPageActivity.mGlobalLocations = await mLocationDataService.GetAll();

            LoginPageActivity.mGlobalStorages = await mStorageDataService.GetAll();

            LoginPageActivity.mGlobalCategories = await mCategoryDataService.GetAll();

            LoginPageActivity.mGlobalUserLocs = await mUserLocationDataService.GetAll();

            LoginPageActivity.mGlobalUserDatas = await mUserDataDataService.GetAll();

            LoginPageActivity.mGlobalShopList = await mShopListDataService.GetAll();

            LoginPageActivity.mGlobalShopItem = await mShopItemDataService.GetAll();

            LoginPageActivity.mGlobalProducts = await mProductDataService.GetAll();

            LoginPageActivity.mGlobalInventories = new List <InventoryViewModel>();

            List <InventoryViewModel> tempInventories = await mInventoryDataService.GetAll();

            for (int i = 0; i < tempInventories.Count(); i++)
            {
                for (int j = 0; j < LoginPageActivity.mGlobalProducts.Count(); j++)
                {
                    if (tempInventories[i].ProductId == LoginPageActivity.mGlobalProducts[j].Id)
                    {
                        tempInventories[i].ItemName = LoginPageActivity.mGlobalProducts[j].Name;
                        LoginPageActivity.mGlobalInventories.Add(tempInventories[i]);
                    }
                    if (LoginPageActivity.mGlobalProducts[j].AddedUserId == LoginPageActivity.StaticUserClass.ID.ToString())
                    {
                        LoginPageActivity.mGlobalProductsByUser.Add(LoginPageActivity.mGlobalProducts[j]);
                    }
                }
            }
        }