Наследование: 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;
 }