public void RemoveRental(string movieTitle, string socialSecurityNumber) { StaticHelp.ValidateSocialSecurityNumber(socialSecurityNumber); var rentalToRemove = _rentals.FirstOrDefault(x => x._movieTitle.ToLower() == movieTitle.ToLower() && x._customerSsn == socialSecurityNumber); _rentals.Remove(rentalToRemove); }
public void ReturnMovie(string movieTitle, string socialSecurityNumber) { //Validate SSN StaticHelp.ValidateSocialSecurityNumber(socialSecurityNumber); //Check if Customer exists Customers.CheckCustomerExsistence(socialSecurityNumber); //Check Movie var rental = Rentals.GetRentalsFor(socialSecurityNumber)?.FirstOrDefault(x => x._movieTitle.ToLower() == movieTitle.ToLower()) ?? throw new MovieDontExistsExeption("Return failed. " + ExeptionMessages.MovieDontExistsExeptionMessage); Rentals.RemoveRental(movieTitle, socialSecurityNumber); if (rental._dueDate < DateTime.Now) { throw new LateRentalExeption(ExeptionMessages.LateReturnExeptionMessage); } }
public void RegisterCustomer(string socialSecurityNumber, string name) { if (string.IsNullOrEmpty(name)) { throw new NameNullOrEmptyExeption(ExeptionMessages.NameNullOrEmptyExeptionMessage); } if (StaticHelp.ValidateSocialSecurityNumber(socialSecurityNumber)) { if (Customers.ContainsKey(socialSecurityNumber)) { throw new CustomerExistsExeption(ExeptionMessages.CustomerExistsExeptionMessage); } else { Customers.Add(socialSecurityNumber, name); } } }
public void RentMovie(string movieTitle, string socialSecurityNumber) { StaticHelp.ValidateSocialSecurityNumber(socialSecurityNumber); ValidateRental(movieTitle, socialSecurityNumber); Rentals.AddRental(movieTitle, socialSecurityNumber); }
public void AddRental(string movieTitle, string socialSecurityNumber) { StaticHelp.ValidateSocialSecurityNumber(socialSecurityNumber); ValidateRental(movieTitle.ToLower(), socialSecurityNumber); _rentals.Add(new Rental(_dateTime.Now().AddDays(3), movieTitle, socialSecurityNumber)); }