public void SendCarOnRent(CarFacade carFacade, Client client, RentTime time)
        {
            CheckCarCanGoOnRent(carFacade, time);

            AddRentHistoryToClient(client, carFacade, time);
            AddRentHistoryToCar(carFacade, time);
        }
        private void AddServiceHistoryToCar(CarFacade carFacade, DateTimeOffset startTime)
        {
            var endTimeOfService = startTime.AddDays(7);
            var serviceTime      = new RentTime(startTime, endTimeOfService);

            carFacade.Car.Services.Add(serviceTime);
            carFacade.Car.SetCountToServiceToZero();
            CarRepository.Update(carFacade.Car);
        }
示例#3
0
 public void RentCar(CarFacade carFacade, RentTime time)
 {
     if (HasCarAt(time))
     {
         throw new Exception("У клиента " + Name + " уже есть машина в аренде во это время: " + time);
     }
     else
     {
         RentHistory.Add(time, carFacade);
     }
 }
        public void SendCarOnService(CarFacade carFacade, DateTimeOffset startTime)
        {
            var endTime = startTime.AddDays(7);
            var time    = new RentTime(startTime, endTime);

            if (carFacade.IsFreeAt(time))
            {
                AddServiceHistoryToCar(carFacade, startTime);
            }
            else
            {
                throw new Exception("Машина " + carFacade.Car.Name + " не может быть отправлена на тех обслуживание в "
                                    + startTime + ", так как занята");
            }
        }
        private void CheckCarCanGoOnRent(CarFacade carFacade, RentTime time)
        {
            if (carFacade.Car.CountToService >= 10)
            {
                throw new Exception("Машину " + carFacade.Car.Name + " нужно отправить на тех осмотр");
            }

            if (carFacade.Car.Rents.Count != 0 &&
                carFacade.Car.Rents.Last().EndTime > time.StartTime)
            {
                throw new Exception("Нельзя отправлять машину " + carFacade.Car.Name +
                                    " в аренду до уже существующей c " + time.StartTime + " до " + time.EndTime);
            }

            if (!carFacade.IsFreeAt(time))
            {
                throw new Exception("Машина " + carFacade.Car.Name + " занята в промежутке от "
                                    + time.StartTime + " до " + time.EndTime);
            }
        }
示例#6
0
 public void RentCar(CarFacade carFacade, RentTime time)
 {
     Client.RentCar(carFacade, time);
 }
 public void SendCarOnService(CarFacade carFacade, DateTimeOffset startTime)
 {
     CarRentCompany.SendCarOnService(carFacade, startTime);
 }
 public void SendCarOnRent(CarFacade carFacade, Client client, RentTime time)
 {
     CarRentCompany.SendCarOnRent(carFacade, client, time);
 }
 public void RemoveCar(CarFacade carFacade)
 {
     CarRentCompany.RemoveCar(carFacade);
 }
 public void AddCar(CarFacade carFacade)
 {
     CarRentCompany.AddCar(carFacade);
 }
 private void AddRentHistoryToCar(CarFacade carFacade, RentTime time)
 {
     carFacade.Car.IncreaseCountToService();
     carFacade.Car.Rents.Add(time);
     CarRepository.Update(carFacade.Car);
 }
 private void AddRentHistoryToClient(Client client, CarFacade carFacade, RentTime time)
 {
     client.RentCar(carFacade, time);
     ClientRepository.Update(client);
 }
 public void RemoveCar(CarFacade carFacade)
 {
     CarRepository.Delete(carFacade.Car);
 }
 public void AddCar(CarFacade carFacade)
 {
     CarRepository.Create(carFacade.Car);
 }