async public Task LoadStocksAsync() { if (IsBusy) { return; } IsBusy = true; try { WPPod.Models.Stock StockSeed = new WPPod.Models.Stock(); ServerStatus status = await ResultMultiple <WPPod.Models.Stock> .WaitForObjectAsync( NesterControl.DeployedApp, true, StockSeed, false); if (status.Code >= 0) { _stocks = status.PayloadToList <WPPod.Models.Stock>(); OnPropertyChanged("Stocks"); } } catch (Exception ex) { Debug.WriteLine(ex); } finally { IsBusy = false; } }
async public Task LoadMenusAsync() { if (IsBusy) { return; } IsBusy = true; try { WPPod.Models.Menu menuSeed = new WPPod.Models.Menu(); ServerStatus status = await ResultMultiple <WPPod.Models.Menu> .WaitForObjectAsync( NesterControl.DeployedApp, true, menuSeed, false); if (status.Code >= 0) { _menus = status.PayloadToList <WPPod.Models.Menu>(); OnPropertyChanged("EditMenus"); SelectedMenu = _menus.FirstOrDefault(); IsBusy = false; await LoadMenuItemsAsync(); } } catch (Exception ex) { Debug.WriteLine(ex); } finally { IsBusy = false; } }
async public Task LoadStockItemsByDateAsync(DateTime date) { if (IsBusy) { return; } IsBusy = true; try { _stockItems.Clear(); WPPod.Models.StockItem itemSummary; foreach (var stock in _stocks) { WPPod.Models.StockItem stockItemSeed = new WPPod.Models.StockItem(); stockItemSeed.Stock = stock; Dictionary <string, string> filter = new Dictionary <string, string>(); filter["date"] = date.ToString("d"); ServerStatus status = await ResultMultiple <WPPod.Models.StockItem> .WaitForObjectAsync( NesterControl.DeployedApp, true, stockItemSeed, false, filter); if (status.Code >= 0) { var itmes = status.PayloadToList <WPPod.Models.StockItem>(); itemSummary = new WPPod.Models.StockItem(); itemSummary.Stock = stock; itemSummary.Quantity = 0; foreach (var calcStockItem in itmes) { itemSummary.Quantity += calcStockItem.Quantity; } if (itmes.Any()) { itemSummary.Unit = itmes.First().Unit; _stockItems.Add(itemSummary); } } } OnPropertyChanged("StockItems"); } catch (Exception ex) { Debug.WriteLine(ex); } finally { IsBusy = false; } }
async public Task <ServerStatus> LoadMenuItemsAsync() { ServerStatus status = new ServerStatus( ServerStatus.NEST_RESULT_ERROR); if (IsBusy) { return(status); } IsBusy = true; try { EditMenuItems.Clear(); WPPod.Models.MenuItem menuItemSeed = new WPPod.Models.MenuItem(); menuItemSeed.Menu = _selectedMenu; status = await ResultMultiple <WPPod.Models.MenuItem> .WaitForObjectAsync( NesterControl.DeployedApp, true, menuItemSeed, false); if (status.Code >= 0) { _menuItems = status.PayloadToList <WPPod.Models.MenuItem>(); OnPropertyChanged("EditMenuItems"); SelectedMenuItem = _menuItems.FirstOrDefault(); } } catch (Exception ex) { Debug.WriteLine(ex); } finally { IsBusy = false; } return(status); }
async public Task LoadOrdersAsync(DateTime date) { if (IsBusy) { return; } IsBusy = true; try { WPPod.Models.Order orderSeed = new WPPod.Models.Order(); Dictionary <string, string> filter = new Dictionary <string, string>(); filter["date"] = date.ToString("yyyy-MM-dd"); ServerStatus status = await ResultMultiple <WPPod.Models.Order> .WaitForObjectAsync( NesterControl.DeployedApp, true, orderSeed, false, filter); if (status.Code >= 0) { _orders = status.PayloadToList <WPPod.Models.Order>(); WPPod.Models.OrderItem itemSeed = new WPPod.Models.OrderItem(); foreach (var order in _orders) { itemSeed.Order = order; status = await ResultMultiple <WPPod.Models.OrderItem> .WaitForObjectAsync( NesterControl.DeployedApp, true, itemSeed); if (status.Code >= 0) { order.Items = status.PayloadToList <WPPod.Models.OrderItem>(); WPPod.Models.MenuItem menuItemSeed = new WPPod.Models.MenuItem(); foreach (var orderItem in order.Items) { menuItemSeed.Menu = new WPPod.Models.Menu(); menuItemSeed.Menu.Id = orderItem.MenuId; menuItemSeed.Id = orderItem.MenuItemId; status = await ResultSingle <WPPod.Models.MenuItem> .WaitForObjectAsync( true, menuItemSeed, new CachedHttpRequest <WPPod.Models.MenuItem>( NesterControl.DeployedApp.QueryAsync), false, null, null); orderItem.MenuItem = status.PayloadToObject <WPPod.Models.MenuItem>(); } } } OnPropertyChanged("Orders"); } } catch (Exception ex) { Debug.WriteLine(ex); } finally { IsBusy = false; } }