private void LoadInventoriesData() { var SelectedStorage = HomeStoragesFragment.mSelectedStorageClass; var temp = LoginPageActivity.mGlobalInventories; mFilteredInventories = temp.Where(i => i.StorageId == SelectedStorage.Id && i.ProductId == HomeFragment.mHomeSelectedInventory.ProductId && i.ExpirationDate < DateTime.Now).ToList(); this.mHomeInventoriesAdapter = new InventoriesRecyclerAdapter(mFilteredInventories, this.Activity); this.mHomeInventoriesAdapter.ItemClick += OnStorageClicked; this.Activity.RunOnUiThread(() => mHomeInventoriesAdapter.NotifyDataSetChanged()); this.Activity.RunOnUiThread(() => this.mListViewStorages.SetAdapter(this.mHomeInventoriesAdapter)); }
private void LoadInventoriesData() { List <InventoryViewModel> mInventories = LoginPageActivity.mGlobalInventories; StorageViewModel SelectedStorage = LoginPageActivity.StaticStorageClass; mFilteredInventories = new List <InventoryViewModel>(); for (int i = 0; i < mInventories.Count; i++) { if (mInventories[i].StorageId == SelectedStorage.Id) { mFilteredInventories.Add(mInventories[i]); } } if (mFilteredInventories != null) { this.mInventoriesAdapter = new InventoriesRecyclerAdapter(mFilteredInventories, this.Activity); this.mInventoriesAdapter.ItemClick += OnInventoryClicked; this.Activity.RunOnUiThread(() => mInventoriesAdapter.NotifyDataSetChanged()); this.Activity.RunOnUiThread(() => this.mListViewInventories.SetAdapter(this.mInventoriesAdapter)); } }
private void InventoryOptions_OnComplete(object sender, OnInventoryDialogPicked e) { var menu = e.MenuItem; if (menu == 1) { if (mSelectedInventoryClass.Id != null) { mProgressBar.Visibility = Android.Views.ViewStates.Visible; Inventorylog newInventoryLog = new Inventorylog() { InventoryId = mSelectedInventoryClass.Id, Description = mSelectedInventoryClass.ItemName + " Used By " + mUser.Username, LogDate = DateTime.Now, CreatedUserId = mUser.ID.ToString(), AddedUserId = mUser.ID.ToString() }; new Thread(new ThreadStart(delegate { var isAdded = mInventoryLogDataService.Add(newInventoryLog); var isDeleted = mInventoryDataService.Delete(mSelectedInventoryClass.Id); if (isDeleted) { UpdateInventories(); LoadInventoriesData(); UpgradeProgress(); this.Activity.RunOnUiThread(() => mInventoriesAdapter.NotifyDataSetChanged()); this.Activity.RunOnUiThread(() => Toast.MakeText(this.Activity, "Item Removed", ToastLength.Long).Show()); ReplaceFragment(new InventoriesFragment(), "Manage Inventories"); mProgressBar.Visibility = Android.Views.ViewStates.Invisible; } else { this.Activity.RunOnUiThread(() => Toast.MakeText(this.Activity, "Failed", ToastLength.Long).Show()); } })).Start(); } } else if (menu == 2) { if (mSelectedInventoryClass.Id != null) { mProgressBar.Visibility = Android.Views.ViewStates.Visible; Inventorylog newInventoryLog = new Inventorylog() { InventoryId = mSelectedInventoryClass.Id, Description = mSelectedInventoryClass.ItemName + " Throwed By " + mUser.Username, LogDate = DateTime.Now, CreatedUserId = mUser.ID.ToString(), AddedUserId = mUser.ID.ToString() }; new Thread(new ThreadStart(delegate { var isAdded = mInventoryLogDataService.Add(newInventoryLog); var isDeleted = mInventoryDataService.Delete(mSelectedInventoryClass.Id); if (isDeleted) { UpdateInventories(); LoadInventoriesData(); UpgradeProgress(); this.Activity.RunOnUiThread(() => mInventoriesAdapter.NotifyDataSetChanged()); this.Activity.RunOnUiThread(() => Toast.MakeText(this.Activity, "Item Removed", ToastLength.Long).Show()); ReplaceFragment(new InventoriesFragment(), "Manage Inventories"); mProgressBar.Visibility = Android.Views.ViewStates.Invisible; } else { this.Activity.RunOnUiThread(() => Toast.MakeText(this.Activity, "Failed", ToastLength.Long).Show()); } })).Start(); } } else if (menu == 3) { if (mSelectedInventoryClass.Id != null) { mProgressBar.Visibility = Android.Views.ViewStates.Visible; Inventorylog newInventoryLog = new Inventorylog() { InventoryId = mSelectedInventoryClass.Id, Description = mSelectedInventoryClass.ItemName + " Removed By " + mUser.Username, LogDate = DateTime.Now, CreatedUserId = mUser.ID.ToString(), AddedUserId = mUser.ID.ToString() }; new Thread(new ThreadStart(delegate { var isAdded = mInventoryLogDataService.Add(newInventoryLog); var isDeleted = mInventoryDataService.Delete(mSelectedInventoryClass.Id); if (isDeleted) { UpdateInventories(); LoadInventoriesData(); UpgradeProgress(); this.Activity.RunOnUiThread(() => mInventoriesAdapter.NotifyDataSetChanged()); this.Activity.RunOnUiThread(() => Toast.MakeText(this.Activity, "Item Removed", ToastLength.Long).Show()); mProgressBar.Visibility = Android.Views.ViewStates.Invisible; } else { this.Activity.RunOnUiThread(() => Toast.MakeText(this.Activity, "Failed", ToastLength.Long).Show()); } })).Start(); } } else { } }