示例#1
0
        private VideoTitle AddTitle(string name, int year, VideoTitle.TitleType titleType)
        {
            var title = new VideoTitle(name, year, repo.Titles.Count + 1);

            title.Type = titleType;
            repo.Titles.Add(title);
            return(title);
        }
示例#2
0
        public RentalOptions CalculateRentalOptions(VideoTitle.TitleType titleType, int rentalDays, int bonusPoints)
        {
            var     terms = allTerms.Find(x => x.TitleType == titleType);
            bool    isPaymentByPointsPossible = IsPaymentByPointsPossible(rentalDays, bonusPoints, terms);
            decimal price         = terms.FlatPeriodFee + GetTrailingDaysPrice(rentalDays, terms);
            int     priceInPoints = GetPriceInPoints(rentalDays, terms);

            return(new RentalOptions(titleType, rentalDays, bonusPoints, isPaymentByPointsPossible, price, priceInPoints));
        }
示例#3
0
 public RentalOptions(VideoTitle.TitleType titleType, int rentalDays, int pointsAvailable,
                      bool isPaymentByPointsPossible, decimal price, int priceInPoints)
 {
     TitleType                 = titleType;
     RentalDays                = rentalDays;
     PointsAvailable           = pointsAvailable;
     IsPaymentByPointsPossible = isPaymentByPointsPossible;
     Price         = price;
     PriceInPoints = priceInPoints;
 }
示例#4
0
        /// <summary>
        /// Return the options for the rental of the film - price and possibility to pay with bonus points.
        /// </summary>
        /// <param name="customerId">ID of the customer.</param>
        /// <param name="titleType">the type of the film.</param>
        /// <param name="dayCount">the number of days to rent.</param>
        /// <returns>Rental options for the customer and the video title.</returns>
        public RentalOptions GetRentalOptions(int customerId, VideoTitle.TitleType titleType, int dayCount)
        {
            int bonusPoints = repository.GetCustomer(customerId).BonusPoints;

            return(pricePolicy.CalculateRentalOptions(titleType, dayCount, bonusPoints));
        }
示例#5
0
 /// <summary>
 /// Changes the type of the title.
 /// </summary>
 /// <param name="titleId">ID of the title.</param>
 /// <param name="type">The new type for the title.</param>
 public void ChangeTitleType(int titleId, VideoTitle.TitleType type)
 {
     repository.GetTitle(titleId).Type = type;
 }
示例#6
0
        public int CalculateBonus(VideoTitle.TitleType titleType, int rentalDays)
        {
            var terms = allTerms.Find(x => x.TitleType == titleType);

            return(terms.PointsForRent);
        }
示例#7
0
        private void AddTitleAndRentCasette(Customer customer, string name, int year, VideoTitle.TitleType titleType)
        {
            var title     = AddTitle(name, year, titleType);
            int casetteId = AddCasette(title);

            AddRental(customer, title, casetteId);
        }
示例#8
0
 public int CalculateBonus(VideoTitle.TitleType titleType, int rentalDays)
 {
     return(BonusPoints);
 }
示例#9
0
 public RentalOptions CalculateRentalOptions(VideoTitle.TitleType titleType, int rentalDays, int bonusPoints)
 {
     return(new RentalOptions(titleType, rentalDays, bonusPoints, false, 0, 0));
 }