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); }
public void RentCar(CarFacade carFacade, RentTime time) { if (HasCarAt(time)) { throw new Exception("У клиента " + Name + " уже есть машина в аренде во это время: " + time); } else { RentHistory.Add(time, carFacade); } }
public bool IsCrossedWith(RentTime time) { var isCrossed = true; if (((StartTime > time.EndTime) && (EndTime > time.EndTime)) || ((StartTime < time.StartTime) && (EndTime < time.EndTime))) { isCrossed = false; } return(isCrossed); }
public List <Car> GetCarsAt(RentTime time) { var cars = new List <Car>(); foreach (var car in CarRepository.GetList()) { if (car.IsFreeAt(time)) { cars.Add(car); } } return(cars); }
public bool IsAtServiceAt(RentTime time) { bool isAtService = false; foreach (var service in Services) { if (time.IsCrossedWith(service)) { isAtService = true; } } return(isAtService); }
public bool IsAtRentAt(RentTime time) { bool isAtRent = false; foreach (var rent in Rents) { if (time.IsCrossedWith(rent)) { isAtRent = true; } } return(isAtRent); }
public bool HasCarAt(RentTime time) { bool hasCar = false; foreach (var rent in RentHistory) { if (time.IsCrossedWith(rent.Key)) { hasCar = true; } } return(hasCar); }
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); } }
public List <Car> GetCarsAt(RentTime time) { return(CarRentCompany.GetCarsAt(time)); }
public bool HasCarAt(RentTime time) { return(Client.HasCarAt(time)); }
public void RentCar(CarFacade carFacade, RentTime time) { Client.RentCar(carFacade, time); }
public bool IsFreeAt(RentTime time) { return(!(IsAtRentAt(time) || IsAtServiceAt(time))); }
public void SendCarOnRent(CarFacade carFacade, Client client, RentTime time) { CarRentCompany.SendCarOnRent(carFacade, client, time); }
private void AddRentHistoryToClient(Client client, CarFacade carFacade, RentTime time) { client.RentCar(carFacade, time); ClientRepository.Update(client); }
public bool IsFreeAt(RentTime time) { return(Car.IsFreeAt(time)); }
public bool IsAtRentAt(RentTime time) { return(Car.IsAtRentAt(time)); }
public bool IsAtServiceAt(RentTime time) { return(Car.IsAtServiceAt(time)); }
private void AddRentHistoryToCar(CarFacade carFacade, RentTime time) { carFacade.Car.IncreaseCountToService(); carFacade.Car.Rents.Add(time); CarRepository.Update(carFacade.Car); }