Beispiel #1
0
        public Rental RentCarToCustomer(string loginEmail, int accountId, int carid, DateTime rentalDate, DateTime returnDate)
        {
            if (rentalDate > DateTime.Now)
            {
                throw new UnableToRentForDateException(string.Format("Can not rent car for date {} yet", rentalDate.ToShortDateString()));
            }

            IAccountRepository accountRepository = _dataRepositoryFactory.GetDataRepository <IAccountRepository>();
            IRentalRepository  rentalRepository  = _dataRepositoryFactory.GetDataRepository <IRentalRepository>();

            Account account = accountRepository.GetByLogin(loginEmail);

            if (account == null)
            {
                throw new NotFoundException(string.Format("Account not found for login {}", loginEmail));
            }

            Rental rental = new Rental
            {
                AccountId    = account.AccountId,
                CarId        = carid,
                DateRented   = rentalDate,
                DateReturned = returnDate
            };

            Rental savedEntity = rentalRepository.Add(rental);

            return(savedEntity);
        }
Beispiel #2
0
 public UnitOfWork(ApplicationDbContext context)
 {
     _context = context;
     Rooms    = new RoomRepository(_context);
     Tenants  = new TenantRepository(_context);
     Rentals  = new RentalRepository(_context);
 }
Beispiel #3
0
        public Car[] GetAllAvailableCars(DateTime pickUpDate, DateTime returnDate)
        {
            string userName = Thread.CurrentPrincipal.Identity.Name;

            return(ExecuteFaultHandledOperation(() => {
                ICarRepository carRepository = _DataRepositoryFactory.GetDataRepository <ICarRepository>();
                IRentalRepository rentalRepository = _DataRepositoryFactory.GetDataRepository <IRentalRepository>();
                IReservationRepository reservationRepository = _DataRepositoryFactory.GetDataRepository <IReservationRepository>();

                ICarRentalEngine engine = _BusinessEngineFactory.GetBusinessEngine <ICarRentalEngine>();

                IEnumerable <Car> allCars = carRepository.Get();
                IEnumerable <Rental> rentedCars = rentalRepository.GetCurrentlyRentedCars();
                IEnumerable <Reservation> reservedCars = reservationRepository.Get();
                List <Car> availablesCars = new List <Car>();

                foreach (var car in allCars)
                {
                    if (engine.IsCarAvailableForRental(car.CarId, pickUpDate, returnDate, rentedCars, reservedCars))
                    {
                        availablesCars.Add(car);
                    }
                }

                return new List <Car>().ToArray();
            }));
        }
Beispiel #4
0
 public RentalsController(
     IRentalRepository rentalRepository,
     IMapper mapper) : base()
 {
     _rentalRepository = rentalRepository;
     _mapper           = mapper;
 }
 public DefectService(IRentalRepository rentalRepository, IScooterRepository scooterRepository,
                      IDefectRepository defectRepository)
 {
     _rentalRepository  = rentalRepository;
     _scooterRepository = scooterRepository;
     _defectRepository  = defectRepository;
 }
Beispiel #6
0
 public UnitOfWork()
 {
     context = new MovieAppContext();
     context.Database.EnsureCreated();
     MovieRepository  = new MovieRepositoryEFMemory(context);
     RentalRepository = new RentalRepository(context);
 }
Beispiel #7
0
        public Rental RentCarToCustomer(string loginEmail, int carId, DateTime rentalDate, DateTime dueDate)
        {
            if (rentalDate > DateTime.Now)
            {
                throw new UnableToRentForDateException($"Can not rent for date {rentalDate} yet");
            }
            IAccountRepository accountRepository = _DataRepositoryFactory.GetDataRepository <IAccountRepository>();
            IRentalRepository  rentalRepository  = _DataRepositoryFactory.GetDataRepository <IRentalRepository>();
            bool carIsRented = IsCarCurrentlyRented(carId);

            if (carIsRented)
            {
                throw new CarCurrentlyRentedException($"Car {carId} is alredy rented");
            }
            Account account = accountRepository.GetByLogin(loginEmail);

            if (account == null)
            {
                throw new NotFoundException($"No account for {loginEmail}");
            }
            Rental rental = new Rental()
            {
                AccountId  = account.AccountId,
                CarId      = carId,
                DateDue    = dueDate,
                DateRented = rentalDate
            };
            Rental savedEntity = rentalRepository.Add(rental);

            return(savedEntity);
        }
Beispiel #8
0
 public RentGameUseCase(
     IRentalRepository rentalRepository,
     IMapper mapper)
 {
     _rentalRepository = rentalRepository;
     _mapper           = mapper;
 }
        public Car[] GetAvailableCars(DateTime pickupDate, DateTime returnDate)
        {
            return(ExecuteFaultHandledOperation(() => {
                ICarRepository carRepository = _DataRepositoryFactory.GetDataRepository <ICarRepository>();
                IRentalRepository rentalRepository = _DataRepositoryFactory.GetDataRepository <IRentalRepository>();
                IReservationRepository reservationRepository = _DataRepositoryFactory.GetDataRepository <IReservationRepository>();

                ICarRentalEngine carRentalEngine = _BusinessEngineFactory.GetBusinessEngine <ICarRentalEngine>();

                IEnumerable <Car> allCars = carRepository.Get();
                IEnumerable <Rental> rentedCars = rentalRepository.GetCurrentlyRentedCars();
                IEnumerable <Reservation> reservedCars = reservationRepository.Get();

                List <Car> availableCars = new List <Car>();

                foreach (Car car in allCars)
                {
                    if (carRentalEngine.IsCarAvailableForRental(car.CarId, pickupDate, returnDate, rentedCars, reservedCars))
                    {
                        availableCars.Add(car);
                    }
                }

                return availableCars.ToArray();
            }));
        }
Beispiel #10
0
 public UnitOfWorkMem()
 {
     context          = new VideoAppContext();
     VideoRepository  = new VideoRepositoryEFMemory(context);
     GenreRepository  = new GenreRepository(context);
     RentalRepository = new RentalRepository(context);
 }
 public RentalService(
     IScooterRepository scooterRepository,
     IRentalRepository rentalRepository)
 {
     _scooterRepository = scooterRepository;
     _rentalRepository  = rentalRepository;
 }
Beispiel #12
0
 public Repository(AppDbContext context, IClientRepository clientRepository, IVehicleRepository vehicleRepository, IRentalRepository rentalRepository)
 {
     appDbContext           = context;
     this.clientRepository  = clientRepository;
     this.vehicleRepository = vehicleRepository;
     this.rentalRepository  = rentalRepository;
 }
Beispiel #13
0
 public HomeController(ILogger <HomeController> logger,
                       IActorRepository actor,
                       IUserRepository customer,
                       IMovieRepository movie,
                       IPast_PurchasesRepository past_purchase,
                       IPurchaseRepository purchase,
                       IRentalRepository rental,
                       IReviewRepository review,
                       ITransactionRepository transaction,
                       IAge_RatingRepository age_rating,
                       IDirectorRepository director,
                       IGenreRepository genre,
                       ICartRepository cart,
                       ITransactionDetailsRepository transactionDetails,
                       AppDbContext context
                       )
 {
     _logger                 = logger;
     _actorList              = actor;
     _customerList           = customer;
     _movieList              = movie;
     _past_purchaseList      = past_purchase;
     _purchaseList           = purchase;
     _rentalList             = rental;
     _reviewList             = review;
     _transactionList        = transaction;
     _age_RatingList         = age_rating;
     _directorList           = director;
     _genreList              = genre;
     _cartList               = cart;
     _transactionDetailsList = transactionDetails;
     _context                = context;
 }
 public RentalController(IMovieRepository movieRepository, ICustomerRepository customerRepository, IRentalRepository rentalRepository, ITransactionRepository transactionRepository)
 {
     this.movieRepository       = movieRepository;
     this.customerRepository    = customerRepository;
     this.rentalRepository      = rentalRepository;
     this.transactionRepository = transactionRepository;
 }
        public void ReturnRental(int inId, IRentalRepository rentalRepository, IBoardGameRepository boardGameRepository)
        {
            rentalRepository.ReturnRental(inId);
            var rental = rentalRepository.GetRentalById(inId);

            boardGameRepository.ReturnBoardGames(new List <BoardGame>(rental.BoardGames));
        }
Beispiel #16
0
 public RentalUpdateHandler(
     IRentalRepository rentalRepository,
     IMovieRepository movieRepository
     )
 {
     _rentalRepository = rentalRepository;
     _movieRepository  = movieRepository;
 }
Beispiel #17
0
 public MainFormController(IWindowFormsFactory inFormFactory, IBoardGameRepository inBoardGameRepository, IMemberRepository inMemberRepository, IUserRepository inUserRepository, IRentalRepository inRentalRepository)
 {
     FormsFactory        = inFormFactory;
     BoardGameRepository = inBoardGameRepository;
     MemberRepository    = inMemberRepository;
     UserRepository      = inUserRepository;
     RentalRepository    = inRentalRepository;
 }
Beispiel #18
0
 public RentalsController(IRentalRepository rentalRepository, IVehicleRepository vehicleRepository, IUserRepository userRepository, IVehicleTypeRepository vehicleTypeRepository, IMapper mapper)
 {
     _userRepository        = userRepository;
     _vehicleRepository     = vehicleRepository;
     _rentalRepository      = rentalRepository;
     _vehicleTypeRepository = vehicleTypeRepository;
     _mapper = mapper;
 }
 /// <summary>
 /// Initializes a new instance of the MessageHandlerBase class.
 /// </summary>
 public GetAvailableCarsHandler(ICarRepository repository, IRentalRepository rentalRepository,
                                IReservationRepository reservationRepository, ICarRentalEngine carRentalEngine)
     : base(repository)
 {
     this.rentalRepository      = rentalRepository;
     this.reservationRepository = reservationRepository;
     this.carRentalEngine       = carRentalEngine;
 }
 public InvoiceRepository(IEventSourcingRepository <Invoice, InvoiceId> eventRepo, ICustomerRepository customerRepository, IShipServiceRepository shipServiceRepository, IShipRepository shipRepository, IRentalRepository rentalRepository)
 {
     _eventRepository       = eventRepo;
     _customerRepository    = customerRepository;
     _shipServiceRepository = shipServiceRepository;
     _shipRepository        = shipRepository;
     _rentalRepository      = rentalRepository;
 }
 public RentalService(
     IMapper mapper,
     IRentalRepository rentalRepository,
     IRentalTypeRepository rentalTypeRepository)
     : base(mapper, rentalRepository)
 {
     _rentalRepository     = rentalRepository;
     _rentalTypeRepository = rentalTypeRepository;
 }
Beispiel #22
0
        public UnitOfWorkMem()
        {
            context = new InMemoryContext();
            context.Database.EnsureCreated();

            VideoRepository  = new VideoRepositoryEFMemory(context);
            GenreRepository  = new GenreRepository(context);
            RentalRepository = new RentalRepository(context);
        }
 public GetGameUseCase(
     IGameRepository gameRepository,
     IRentalRepository rentalRepository,
     IMapper mapper)
 {
     _gameRepository   = gameRepository;
     _rentalRepository = rentalRepository;
     _mapper           = mapper;
 }
Beispiel #24
0
 public UnitOfWork(ApplicationDbContext context)
 {
     _context        = context;
     Customers       = new CustomerRepository(_context);
     Movies          = new MovieRepository(_context);
     MembershipTypes = new MembershipTypeRepository(_context);
     Genres          = new GenreRepository(_context);
     Rentals         = new RentalRepository(_context);
 }
Beispiel #25
0
 public ContactService(
     IMapper mapper,
     ILoggerFactory loggerFactory,
     IRentalRepository rentalRepository)
 {
     _mapper           = mapper;
     _rentalRepository = rentalRepository;
     _logger           = loggerFactory.CreateLogger <ContactService>();
 }
 public RentalService(IRentalRepository rentalRepository, IUserRepository userRepository,
                      IBookRepository bookRepository, IMapper mapper, ISetRepository setRepository)
 {
     _rentalRepository = rentalRepository;
     _userRepository   = userRepository;
     _bookRepository   = bookRepository;
     _setRepository    = setRepository;
     _mapper           = mapper;
 }
Beispiel #27
0
 public RentalHandler(
     RentalDomainService rentalDomainService,
     IRentalRepository rentalRepository,
     IItemRepository itemRepository)
 {
     _rentalDomainService = rentalDomainService;
     _rentalRepository    = rentalRepository;
     _itemRepository      = itemRepository;
 }
 public RentalService(
     IRentalRepository rentalRepository,
     IMovieService movieService,
     ICustomerService customerService,
     INotifier notifier) : base(notifier)
 {
     _rentalRepository = rentalRepository;
     _movieService     = movieService;
     _customerService  = customerService;
 }
Beispiel #29
0
 public Handler(
     IRentalRepository rentalRepository,
     ICarRepository carRepository,
     ICustomerRepository customerRepository,
     IMapper mapper)
 {
     _rentalRepository   = rentalRepository;
     _carRepository      = carRepository;
     _customerRepository = customerRepository;
     _mapper             = mapper;
 }
Beispiel #30
0
        public bool IsCarCurrentlyRented(int carId)
        {
            IRentalRepository rentalRepository = _dataRepositoryFactory.GetDataRepository <IRentalRepository>();
            var currentRental = rentalRepository.GetCurrentRentalByCar(carId);

            if (currentRental != null)
            {
                return(true);
            }

            return(false);
        }
Beispiel #31
0
 public RentalsEngine(IMovieRepository movieRepository, IDvdItemRepository dvdItemRepository, IRentalRepository rentalRepository)
 {
     _movieRepository = movieRepository;
     _dvdItemRepository = dvdItemRepository;
     _rentalRepository = rentalRepository;
 }
Beispiel #32
0
 public RentalsController()
 {
     this._rentalRepository = new RentalRepository();
 }
Beispiel #33
0
 public RentalsController(IRentalRepository rentalRepository)
 {
     this._rentalRepository = rentalRepository;
 }
 public CarRentalEngine(IRentalRepository rentalRepository, IAccountRepository accountRepository)
 {
     this.rentalRepository = rentalRepository;
     this.accountRepository = accountRepository;
 }