Esempio n. 1
0
File: Store.cs Progetto: fswong/WDT1
        /// <summary>
        /// if there is sufficient quantity in the store, reduce the store quantity
        /// </summary>
        /// <param name="store"></param>
        /// <param name="ProductID"></param>
        /// <param name="Quantity"></param>
        /// <returns></returns>
        public BusinessObject.Store PurchaseItem(BusinessObject.Store store, int ProductID, int Quantity)
        {
            try
            {
                // TODO pass this to the BO
                //get the item from the store
                var siRepo = new StoreInventoryRepository();
                var item   = siRepo.GetStoreInventoryByStoreIdAndProductId(StoreID: store._poco.StoreID, ProductID: ProductID);

                // validate that there is enough stock
                if (item.StockLevel >= Quantity)
                {
                    int newStock = item.StockLevel - Quantity;
                    siRepo.UpdateStoreInventory(StoreID: store._poco.StoreID, ProductID: ProductID, Quantity: newStock);

                    // refresh the store's inventory
                    // this is the stores internal private method, so this logic has to move into the store
                }
                else
                {
                    throw new Exception("Insufficient stock to process this request");
                }
                return(store);
            }
            catch (Exception)
            {
                throw;
            }
        }
Esempio n. 2
0
File: Store.cs Progetto: fswong/WDT1
 /// <summary>
 /// idk why this is here, this is technically just to follow hte architecture, the user already has access to the
 /// </summary>
 /// <param name="store"></param>
 /// <returns></returns>
 public List <DataObject.StoreInventory> ListStoreProducts(BusinessObject.Store store)
 {
     try {
         return(store.ListStoreInventory());
     }
     catch (Exception) {
         throw;
     }
 }
Esempio n. 3
0
File: Store.cs Progetto: fswong/WDT1
 /// <summary>
 /// create a store request
 /// </summary>
 /// <param name="store"></param>
 /// <param name="ProductID"></param>
 /// <param name="Quantity"></param>
 public void RequestStock(BusinessObject.Store store, int ProductID, int Quantity)
 {
     try
     {
         // TODO pass this to the BO
         new StockRequestRepository().CreateStockRequest(store._poco.StoreID, ProductID, Quantity);
     }
     catch (Exception)
     {
         throw;
     }
 }
Esempio n. 4
0
File: Store.cs Progetto: fswong/WDT1
 /// <summary>
 /// if the item does not exist in the store add the item with one quantity
 /// </summary>
 /// <param name="store"></param>
 /// <param name="ProductID"></param>
 public BusinessObject.Store AddNewInventoyItem(BusinessObject.Store store, int ProductID)
 {
     try
     {
         store.AddToInventory(ProductID);
         return(store);
     }
     catch (Exception)
     {
         throw;
     }
 }