Exemplo n.º 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);
        }
Exemplo n.º 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);
            }
        }
Exemplo n.º 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);
                }
            }
        }
Exemplo n.º 4
0
 public void RentMovie(string movieTitle, string socialSecurityNumber)
 {
     StaticHelp.ValidateSocialSecurityNumber(socialSecurityNumber);
     ValidateRental(movieTitle, socialSecurityNumber);
     Rentals.AddRental(movieTitle, socialSecurityNumber);
 }
Exemplo n.º 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));
 }