protected internal void End(RentPoint rentPoint, DateTime endTime, decimal sum) { if (rentPoint == null) { throw new ArgumentNullException(nameof(rentPoint)); } if (IsEnded) { throw new InvalidOperationException("Rent is already ended"); } EndedAt = endTime; EndRentPoint = rentPoint; EndRentPoint.CashBox.PutMoney(sum); Bike.Return(EndRentPoint); EndRentPoint.AddBike(Bike); if (StartRentPoint == EndRentPoint) { EndRentPoint.Safe.ReturnDeposit(Deposit); } else { if (Deposit.Type == DepositTypes.Passport) { throw new InvalidOperationException("No such passport here"); } EndRentPoint.CashBox.TakeMoney(((MoneyDeposit)Deposit).Sum); StartRentPoint.Safe.MoveMoneyToCashBox(StartRentPoint.CashBox, ((MoneyDeposit)Deposit).Sum); } }
protected internal void LockOnRentPoint(RentPoint rentPoint) { if (rentPoint == null) { throw new ArgumentNullException(nameof(rentPoint)); } RentPoint = rentPoint; }
protected internal void Return(RentPoint rentPoint) { if (IsFree) { throw new InvalidOperationException("Bike is free"); } RentPoint = rentPoint; }
protected internal void Take() { if (!IsFree) { throw new InvalidOperationException("Bike is not free"); } RentPoint = null; }
protected internal void End(RentPoint rentPoint, decimal sum) { if (rentPoint == null) { throw new ArgumentNullException(nameof(rentPoint)); } EndRentPoint = rentPoint; EndRentPoint.Cashbox.PutMoney(sum); Bike.Return(); Bike.LockOnRentPoint(EndRentPoint); Bike.MoveTo(EndRentPoint); }
protected internal void End(RentPoint rentPoint) { if (rentPoint == null) { throw new ArgumentNullException(nameof(rentPoint)); } if (IsEnded) { throw new InvalidOperationException("Rent is already ended"); } EndedAt = DateTime.UtcNow; EndRentPoint = rentPoint; EndRentPoint.PutMoney(Sum.Value); Bike.Return(); Bike.MoveTo(EndRentPoint); EndRentPoint.ReturnDeposit(Deposit); }
public void MoveTo(RentPoint rentPoint) { if (rentPoint == null) { throw new ArgumentNullException(nameof(rentPoint)); } if (rentPoint == RentPoint) { return; } RentPoint?.RemoveBike(this); rentPoint.AddBike(this); RentPoint = rentPoint; }
public void MoveTo(RentPoint rentPoint) { if (!IsFree) { throw new InvalidOperationException("Bike is not free"); } if (rentPoint == null) { throw new ArgumentNullException(nameof(rentPoint)); } if (rentPoint == RentPoint) { return; } RentPoint?.RemoveBike(this); rentPoint.AddBike(this); RentPoint = rentPoint; }