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); }
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)); }
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; }
/// <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)); }
/// <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; }
public int CalculateBonus(VideoTitle.TitleType titleType, int rentalDays) { var terms = allTerms.Find(x => x.TitleType == titleType); return(terms.PointsForRent); }
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); }
public int CalculateBonus(VideoTitle.TitleType titleType, int rentalDays) { return(BonusPoints); }
public RentalOptions CalculateRentalOptions(VideoTitle.TitleType titleType, int rentalDays, int bonusPoints) { return(new RentalOptions(titleType, rentalDays, bonusPoints, false, 0, 0)); }