Beispiel #1
0
        public string GenerateCarCategoryStatement()
        {
            CarCategoryStatement carCategoryStatement = new CarCategoryStatement(Name);

            foreach (PriceCode carCategory in Enum.GetValues(typeof(PriceCode)))
            {
                double rentalSum  = 0;
                var    factory    = new PriceCodeCalculatorFactory();
                var    calculator = factory.GetRentalSumCalculator(carCategory);

                foreach (var rental in _rentals)
                {
                    if (carCategory == rental.Car.PriceCode)
                    {
                        double preDisRentalSum = 0;
                        preDisRentalSum += calculator.GetRentalSum(rental.DaysRented, PricePerDay);

                        if ((renterPointsManager.GetCustomerRenterPoints(rental.Customer.Name, rental.Id) - renterPointsManager.CalculateRenterPoints(rental.Car.PriceCode, rental.DaysRented)) >= 5 && rental.Car.PriceCode != PriceCode.Luxury)
                        {
                            preDisRentalSum = calculator.ApplyDiscount(preDisRentalSum);
                        }

                        rentalSum += preDisRentalSum;
                    }
                }
                carCategoryStatement.AddCarCategoryDetails(carCategory, rentalSum);
            }

            return(carCategoryStatement.GetStatement());
        }
Beispiel #2
0
        public string GenerateStatement()
        {
            GeneralStatement statementBuilder = new GeneralStatement(Name);

            double totalAmount = 0;
            var    factory     = new PriceCodeCalculatorFactory();

            foreach (var rental in _rentals)
            {
                double    rentalSum  = 0;
                int       daysRented = rental.DaysRented;
                PriceCode priceCode  = rental.Car.PriceCode;
                var       calculator = factory.GetRentalSumCalculator(priceCode);

                rentalSum = calculator.GetRentalSum(daysRented, PricePerDay);

                int customerRenterPoints = renterPointsManager.GetCustomerRenterPoints(rental.Customer.Name, rental.Id);
                if (customerRenterPoints - renterPointsManager.CalculateRenterPoints(priceCode, daysRented) >= 5 && priceCode != PriceCode.Luxury)
                {
                    rentalSum = calculator.ApplyDiscount(rentalSum);
                }

                statementBuilder.AddRentalDetails(rental.Customer.Name, customerRenterPoints, priceCode, rental.Car.Model, rental.DaysRented, rentalSum);
                totalAmount += rentalSum;
            }
            statementBuilder.AddTotalAmmount(totalAmount);

            return(statementBuilder.GetStatement());
        }