public StockItem BookItemOutOfStock(Stock stock, decimal quantity, Unit unit, RecipeableItem recipeableItem) { if (stock == null) throw new ArgumentNullException("stock"); var stockItem = FindStockItem(stock, unit, recipeableItem, stock.IsMainStock); var bookQuantity = _unitConverter.Convert(quantity, unit, stockItem.Unit); stockItem.Quantity -= bookQuantity; return stockItem; }
internal StockItem FindStockItem(Stock stock, Unit unit, RecipeableItem recipeableItem, bool createIfNotExists) { if (recipeableItem == null) throw new ArgumentNullException("recipeableItem"); if (unit == null) throw new ArgumentNullException("unit"); var stockItem = stock.StockItems.Where(x => x.RecipeableItem == recipeableItem).FirstOrDefault(); if (stockItem == null) { if( !createIfNotExists ) throw new InvalidOperationException(); stockItem = new StockItem { RecipeableItem = recipeableItem, Unit = unit }; stock.AddStockItem(stockItem); } return stockItem; }
public ObservableCollection<EditStockMovementItem> GetItemsToMove(Stock stock) { var items = new ObservableCollection<EditStockMovementItem>(); if (stock != null) { if (!stock.IsMainStock) { stock.StockItems.Each( si => items.Add(new EditStockMovementItem(si.RecipeableItem, si.Unit) {QuantityLeft = si.Quantity})); } else { var query = _dbConversation.Query(new AllRecipeableItemsQuery()); query.Each( ri => items.Add(new EditStockMovementItem(ri, ri.RecipeUnit))); } } return items; }
public new StockItem FindStockItem(Stock stock, Unit unit, RecipeableItem recipeableItem, bool createIfNotExists) { return base.FindStockItem(stock, unit, recipeableItem, createIfNotExists); }
public EditStock(Stock stock) { Stock = stock; }
void OnStockChanged(Stock stock) { var viewmodel = (from vm in AllStocks where vm.Id == stock.Id select vm).FirstOrDefault(); if (viewmodel == null) { viewmodel = new SingleStockViewModel(stock); AllStocks.Add(viewmodel); } else { viewmodel.ExchangeData(stock); } OnPropertyChanged("ItemSelected"); OnPropertyChanged("ItemsSelected"); }
public SingleStockViewModel(Stock stock) { _stock = stock; base.DisplayName = stock.Name; }
public void ExchangeData(Stock stock) { _stock = stock; }