Ejemplo n.º 1
0
        protected Transaction(Transaction transaction)
        {
            this.customer = transaction.customer;
            this.film = transaction.film;
            this.days = transaction.days;
            this.price = transaction.price;
            this.bonusPoints = transaction.bonusPoints;
            this.bonusable = transaction.bonusable;

            if (transaction.useBonus != null) this.useBonus = transaction.useBonus;
            else this.useBonus = false;
        }
Ejemplo n.º 2
0
        public ConfirmedTransaction(Transaction transaction)
            : base(transaction)
        {
            if (this.useBonus && this.bonusable)
            {
                this.price = 0;
                this.customer.DischargeBonus(this.bonusPoints);
            }
            else
            {
                this.bonusPoints = 0;
                this.customer.ChargeBonus(this.film.FilmType);
            }

            this.timeOfTransaction = DateTime.Now;
            this.film.Status = false;
        }
        public string CreateTransaction(int customerId, int filmId, int numberOfDays)
        {
            this.currentTransaction = null;
            if (this.customersList.customers.ContainsKey(customerId) && this.storeInventory.GetAvailableFilms().Find(s => s.FilmId == filmId) != null && numberOfDays > 0)
            {
                currentTransaction = new Transaction(this.customersList.customers[customerId], this.storeInventory.GetAvailableFilms().Find(s => s.FilmId == filmId), numberOfDays);
                return currentTransaction.GetPriceString();
            }

            throw new ArgumentException(string.Format("invalid values {0} {1} {2}", customerId, filmId, numberOfDays), "customerId, filmId, numberOfDays");
        }