Beispiel #1
0
        /* User has already found the matching product ID.
         * First line findes the store storage
         * Second line subtracts the amount sold from Shop storage*/
        public void MatchTempProduct(TempProduct tempProductToMatch, int matchedProductID)
        {
            Product MatchedProduct = ProductDictionary[matchedProductID];

            tempProductToMatch.Resolve(MatchedProduct);
            SaleTransaction tempProductsTransaction = tempProductToMatch.GetTempProductsSaleTransaction();

            //Gets the Shop storage room, which has = 1, but if it doesn't exist, gets the next one
            if (MatchedProduct.StorageWithAmount.Count == 0)
            {
                MatchedProduct.StorageWithAmount.TryAdd(1, 0);
            }
            KeyValuePair <int, int> StorageRoomStatus = MatchedProduct.StorageWithAmount.First();

            MatchedProduct.StorageWithAmount[StorageRoomStatus.Key] = StorageRoomStatus.Value - tempProductsTransaction.Amount;
            MatchedProduct.UpdateInDatabase();
        }
Beispiel #2
0
        public void RematchTempProduct(TempProduct tempProductToMatch, int matchedProductID)
        {
            Product PreviouslyMatchdProduct           = ProductDictionary[tempProductToMatch.ResolvedProductID];
            KeyValuePair <int, int> StorageRoomStatus = PreviouslyMatchdProduct.StorageWithAmount.Where(x => x.Key != 0).First();

            PreviouslyMatchdProduct.StorageWithAmount[StorageRoomStatus.Key] = StorageRoomStatus.Value + tempProductToMatch.GetTempProductsSaleTransaction().Amount;
            PreviouslyMatchdProduct.UpdateInDatabase();

            MatchTempProduct(tempProductToMatch, matchedProductID);
        }