public GameStoreViewModel(IDispatcherService dispatcherService, string functionTag, IDialogService dialogService, ScoreInfoService scoreInfoService, GoodsService goodsService) : base(dispatcherService, functionTag) { _dialogService = dialogService; _scoreInfoService = scoreInfoService; _goodsService = goodsService; DataGridItemChanged = new RelayCommand <DataGridItemChangedEventArgs>(OnDataGridItemChanged); RefreshList = new RelayCommand(PrivateRefreshList); RemoveItem = new RelayCommand(() => { if (_dialogService.ShowOKCancel("确定删除选中数据吗?")) { _ = _goodsService.RemoveAsync(SelectedItem); GoodsItems.Remove(SelectedItem); } }, () => { return(SelectedItem != null); }); RemoveAll = new RelayCommand(() => { if (_dialogService.ShowOKCancel("确定删除所有数据吗?")) { _ = _goodsService.RemoveAllAsync(); GoodsItems = null; } }, () => { return(GoodsItems != null); }); AddData = new RelayCommand(() => { if (string.IsNullOrEmpty(BuyCmd)) { _dialogService.ShowInformation("购买命令不能为空"); return; } if (GoodsItems.FirstOrDefault(p => p.BuyCmd == BuyCmd) != null) { _dialogService.ShowInformation("购买命令重复"); return; } var dto = new GoodsDto() { GoodsName = GoodsName, BuyCmd = BuyCmd, Content = Content, Amount = Amount, Quality = Quality, Price = Price, GoodsType = GoodsType }; _ = _goodsService.AddAsync(dto); GoodsItems.Add(dto); }); AddAvailableVariables(); PrivateRefreshList(); }
public async Task Refresh() { _receiptItems.Clear(); _goodsItems.Clear(); List <AlbumItem> receipts = await _azure.GetAllImages(CurrentTransaction.ID, true); foreach (AlbumItem t in receipts) { Receipts.Add(t); } receipts.Add(new AlbumItem { IsAddButton = true, IsReceipt = true }); int i = 0; ImageListItems tempILI = new ImageListItems(); foreach (AlbumItem t in receipts) { //RESET temp class for next ListEntry if (tempILI == null) { tempILI = new ImageListItems(); } //Add Image tempILI.ItemImages.Add(t); //Add ListEntry content and reset for next Entry if (i >= 3) { ReceiptItems.Add(tempILI); tempILI = null; i = 0; } i++; } //Fill aditional spaces with filler image if (tempILI != null) { for (int j = tempILI.ItemImages.Count; j < 3; j++) { tempILI.ItemImages.Add(new AlbumItem()); } ReceiptItems.Add(tempILI); } //Reset Values to refresh Goods tempILI = null; i = 0; List <AlbumItem> goods = await _azure.GetAllImages(CurrentTransaction.ID, false); foreach (AlbumItem t in goods) { Goods.Add(t); } goods.Add(new AlbumItem { IsAddButton = true, IsReceipt = false }); foreach (AlbumItem t in goods) { if (tempILI == null) { tempILI = new ImageListItems(); } tempILI.ItemImages.Add(t); if (i >= 3) { GoodsItems.Add(tempILI); tempILI = null; i = 0; } i++; } //Fill aditional spaces with filler image if (tempILI != null) { for (int j = tempILI.ItemImages.Count; j < 3; j++) { tempILI.ItemImages.Add(new AlbumItem()); } GoodsItems.Add(tempILI); } HockeyApp.MetricsManager.TrackEvent("Images Page Loaded"); }
public async Task Refresh() { // NEED TO REWORK FOR THE NEW VIEW - OUTDATED IsLoading = true; #region Receipts Receipts.Clear(); List <AlbumItem> receipts = await _azure.GetAllImages(CurrentTransaction.ID, true); foreach (AlbumItem t in receipts) { Receipts.Add(t); } receipts.Add(new AlbumItem { IsAddButton = true, IsReceipt = true }); int i = 0; ImageListItems tempILI = new ImageListItems(); //ClearItems before applying new items ReceiptItems.Clear(); foreach (AlbumItem t in receipts) { //RESET temp class for next ListEntry if (tempILI == null) { tempILI = new ImageListItems(); } //Add Image tempILI.ItemImages.Add(t); //Add ListEntry content and reset for next Entry if (i >= 3) { ReceiptItems.Add(tempILI); tempILI = null; i = 0; } i++; } //Fill aditional spaces with filler image if (tempILI != null) { for (int j = tempILI.ItemImages.Count; j < 3; j++) { tempILI.ItemImages.Add(new AlbumItem()); } ReceiptItems.Add(tempILI); } #endregion //Reset Values to refresh Goods tempILI = null; i = 0; #region Goods Goods.Clear(); List <AlbumItem> goods = await _azure.GetAllImages(CurrentTransaction.ID, false); foreach (AlbumItem t in goods) { Goods.Add(t); } goods.Add(new AlbumItem { IsAddButton = true, IsReceipt = false }); //ClearItems before applying new items GoodsItems.Clear(); foreach (AlbumItem t in goods) { if (tempILI == null) { tempILI = new ImageListItems(); } tempILI.ItemImages.Add(t); if (i >= 3) { GoodsItems.Add(tempILI); tempILI = null; i = 0; } i++; } //Fill aditional spaces with filler image if (tempILI != null) { for (int j = tempILI.ItemImages.Count; j < 3; j++) { tempILI.ItemImages.Add(new AlbumItem()); } GoodsItems.Add(tempILI); } #endregion List <AlbumItem> images = await _azure.GetAllImages(CurrentTransaction.ID); foreach (AlbumItem image in images) { Images.Add(image); } if (!IsUnitTesting) { HockeyApp.MetricsManager.TrackEvent("Images Page Loaded"); } IsLoading = false; }