예제 #1
0
        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);
        }
예제 #2
0
        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);
            }
        }
예제 #3
0
        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);
                }
            }
        }
예제 #4
0
 public void RentMovie(string movieTitle, string socialSecurityNumber)
 {
     StaticHelp.ValidateSocialSecurityNumber(socialSecurityNumber);
     ValidateRental(movieTitle, socialSecurityNumber);
     Rentals.AddRental(movieTitle, socialSecurityNumber);
 }
예제 #5
0
 public void AddRental(string movieTitle, string socialSecurityNumber)
 {
     StaticHelp.ValidateSocialSecurityNumber(socialSecurityNumber);
     ValidateRental(movieTitle.ToLower(), socialSecurityNumber);
     _rentals.Add(new Rental(_dateTime.Now().AddDays(3), movieTitle, socialSecurityNumber));
 }