Inheritance: DomainEntity
示例#1
0
        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;
        }
示例#2
0
        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;
        }
示例#3
0
 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;
 }
示例#4
0
 public new StockItem FindStockItem(Stock stock, Unit unit, RecipeableItem recipeableItem, bool createIfNotExists)
 {
     return base.FindStockItem(stock, unit, recipeableItem, createIfNotExists);
 }
示例#5
0
 public EditStock(Stock stock)
 {
     Stock = stock;
 }
示例#6
0
 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");
 }
示例#7
0
 public SingleStockViewModel(Stock stock)
 {
     _stock = stock;
     base.DisplayName = stock.Name;
 }
示例#8
0
 public void ExchangeData(Stock stock)
 {
     _stock = stock;
 }