/// <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; } }
/// <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; } }
/// <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; } }
/// <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; } }