Ejemplo n.º 1
0
 public void AcceptCarReturn(int carId)
 {
     ExecuteFaultHandledOperation(() => {
         IRentalRepository rentalRepository = _DataRepositoryFactory.GetDataRepository <IRentalRepository>();
         ICarRentalEngine carRentalEngine   = _BusinessEngineFactory.GetBusinessEngine <ICarRentalEngine>();
         Rental rental = rentalRepository.GetRentalByCar(carId);
         if (rental == null)
         {
             CarNotRentedException ex = new CarNotRentedException($"Car id {carId} is not currently rented");
             throw new FaultException <CarNotRentedException>(ex, ex.Message);
         }
         rental.DateReturned        = DateTime.Now;
         Rental updatedRentalEntity = rentalRepository.Update(rental);
     });
 }
Ejemplo n.º 2
0
        public void AcceptCarReturn(int carId)
        {
            ExecuteFaultHandledOperation(() =>
            {
                var rentalRepository = _DataRepositoryFactory.GetDataRepository<IRentalRepository>();

                var rental = rentalRepository.GetCurrentRentalByCar(carId);
                if (rental == null)
                {
                    var ex = new CarNotRentedException(string.Format("Car {0} is not currently rented.", carId));
                    throw new FaultException<CarNotRentedException>(ex, ex.Message);
                }

                rental.DateReturned = DateTime.Now;

                var updatedRentalEntity = rentalRepository.Update(rental);
            });
        }
Ejemplo n.º 3
0
        public void AcceptCarReturn(int carId)
        {
            ExecuteFaultHandledOperation(() =>
            {
                var rentalRepository = _DataRepositoryFactory.GetDataRepository <IRentalRepository>();

                var rental = rentalRepository.GetCurrentRentalByCar(carId);
                if (rental == null)
                {
                    var ex = new CarNotRentedException(string.Format("Car {0} is not currently rented.", carId));
                    throw new FaultException <CarNotRentedException>(ex, ex.Message);
                }

                rental.DateReturned = DateTime.Now;

                var updatedRentalEntity = rentalRepository.Update(rental);
            });
        }
        public void AcceptCarReturn(int carId)
        {
            base.ExecuteFaultHandledOperation(() =>
            {
                var rentalRepository = this._dataRepositoryFactory.GetDataRepository <IRentalRepository>();
                var carRentalEngine  = this._businessEngineFactory.GetBusinessEngine <ICarRentalEngine>();

                var rental = rentalRepository.GetCurrentRentalByCar(carId);
                if (rental == null)
                {
                    var ex = new CarNotRentedException($"Car {carId} is not currently rented.");
                    throw new FaultException <CarNotRentedException>(ex, ex.Message);
                }

                rental.DateReturned = DateTime.Now;

                rentalRepository.Update(rental);
            });
        }