Exemplo n.º 1
0
        public void RemoveTransaction(int productID)
        {
            SaleTransaction placeholderTransaction = FindTransactionFromProductID(productID);

            Transactions.Remove(placeholderTransaction);
            UpdateTotalPrice();
            UpdateNumberOfProducts();
        }
Exemplo n.º 2
0
 public void AddTransaction(SaleTransaction transaction)
 {
     //Checks if product is already in reciept//
     if (IsProductInReceipt(transaction.Product))
     {
         Transaction placeholderTransaction = GetTransactionWithProduct(transaction.Product);
         placeholderTransaction.Edit(placeholderTransaction.Amount += transaction.Amount);
     }
     else
     {
         Transactions.Add(transaction);
     }
     TotalPrice += FindTransactionPrice(transaction);
     UpdateNumberOfProducts();
 }
Exemplo n.º 3
0
        private decimal FindTransactionPrice(SaleTransaction transaction)
        {
            decimal priceTotal = 0;

            if (transaction.Product is Product)
            {
                if ((transaction.Product as Product).DiscountBool)
                {
                    priceTotal = transaction.Amount * (transaction.Product as Product).DiscountPrice;
                }
                else
                {
                    priceTotal = transaction.Amount * (transaction.Product as Product).SalePrice;
                }
            }
            else if (transaction.Product is TempProduct)
            {
                priceTotal = transaction.Amount * (transaction.Product as TempProduct).SalePrice;
            }
            else if (transaction.Product is ServiceProduct)
            {
                if ((transaction.Product as ServiceProduct).GroupLimit > transaction.Amount)
                {
                    priceTotal += (transaction.Product as ServiceProduct).SalePrice;
                }
                else
                {
                    priceTotal += (transaction.Product as ServiceProduct).GroupPrice;
                }
            }
            else
            {
                throw new WrongProductTypeException("Transaktionens produkt har ikke en valid type!");
            }

            return(priceTotal);
        }