Exemplo n.º 1
0
 private OrderCar(RentalCarId rentalCarId, double pricePerDay, DateTime rentalStartDate, DateTime rentalEndDate)
 {
     Id              = new OrderCarId(Guid.NewGuid());
     RentalCarId     = rentalCarId;
     PricePerDay     = pricePerDay;
     RentalStartDate = rentalStartDate;
     RentalEndDate   = rentalEndDate;
 }
Exemplo n.º 2
0
        public static OrderCar Create(RentalCarId rentalCarId, double pricePerDay, DateTime rentalStartDate, DateTime rentalEndDate)
        {
            if ((rentalEndDate - rentalStartDate).TotalDays < 1)
            {
                throw new OrderCarRentalTooShortException($"Cannot create car rental shorter than 1 day");
            }

            return(new OrderCar(rentalCarId, pricePerDay, rentalStartDate, rentalEndDate));
        }
Exemplo n.º 3
0
        public void AddAgencyRentalCar(AgencyId agencyId, RentalCarId rentalCarId)
        {
            var agency = agencies.FirstOrDefault(x => x.Id == agencyId);

            if (agency == null)
            {
                throw new AgencyNotFoundException($"Unable to add rental car. AgencyId: {agencyId} does not exists" +
                                                  $"in a company with Id: {Id}");
            }

            agency.AddRentalCar(rentalCarId);
        }
Exemplo n.º 4
0
        public void AddRentalCar(RentalCarId rentalCarId)
        {
            if (RentalCars.Any(x => x.Id == rentalCarId.Id))
            {
                throw new RentalCarAlreadyAddedException($"Cannot add rentalCarId: {rentalCarId} because It exists in agency");
            }

            if (RentalCars.Count > 30)
            {
                throw new RentalCarsInAgencyExceededException($"Agency cannot contains more than 30 cars");
            }

            RentalCars.Add(rentalCarId);
        }