Пример #1
0
 private IUnitOfWork CreateUnitOfWork(RentalCarsContext context)
 {
     return(new UnitOfWork(
                rentalCarsContext: context,
                rentalRepository: new RentalRepository(context),
                rentalCarRepository: new RentalCarRepository(context),
                customerRepository: new CustomerRepository(context),
                carCategoryRepository: new CarCategoryRepository(context)));
 }
Пример #2
0
        public void Setup()
        {
            var context = new RentalCarsContext(options);

            this.context = context;

            this.unitOfWork    = CreateUnitOfWork(context);
            this.rentalService = new RentalService(unitOfWork, new PriceCalculator(new Settings(baseDayRental: 700, kilometerPrice: 3)));
        }
Пример #3
0
 public UnitOfWork(
     RentalCarsContext rentalCarsContext,
     IRentalRepository rentalRepository,
     IRentalCarRepository rentalCarRepository,
     ICustomerRepository customerRepository,
     ICarCategoryRepository carCategoryRepository)
 {
     this.context = rentalCarsContext;
     Rental       = rentalRepository;
     RentalCar    = rentalCarRepository;
     Customer     = customerRepository;
     CarCategory  = carCategoryRepository;
 }
Пример #4
0
        public static async Task Run()
        {
            var context       = new RentalCarsContext();
            var rentalService = new RentalService(
                unitOfWork: new UnitOfWork(context, new RentalRepository(context), new RentalCarRepository(context), new CustomerRepository(context), new CarCategoryRepository(context)),
                priceCalculator: new PriceCalculator(new Settings(100, 200)));

            //var rental = await rentalService.RegisterRental(from: DateTime.Now, to: DateTime.Now.AddDays(1), carMilageKm: 144, customerId: 1, rentalCarId: 1);
            var newCustomer = new NewCustomer("Test", $"{Guid.NewGuid()}@test.se", new DateTime(year: 2021, month: 03, day: 15));
            var rental      = await rentalService.RegisterRentalAndCreateCustomer(from : DateTime.Now, to : DateTime.Now.AddDays(1), carMilageKm : 144, newCustomer : newCustomer, rentalCarId : 1);

            rental = await rentalService.RentalReturn(bookingNumber : rental.BookingNumber, returnedAt : DateTime.Now.AddMinutes(1), carMilageKm : 150);
        }
Пример #5
0
 public CustomerRepository(RentalCarsContext context)
 {
     this.context = context;
 }
Пример #6
0
 public CarCategoryRepository(RentalCarsContext context)
 {
     this.context = context;
 }
Пример #7
0
 public RentalRepository(RentalCarsContext context)
 {
     this.context = context;
 }