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); } }
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) { this.LockOnRentPoint(rentPoint); rentPoint.AddBike(this); return; } RentPoint?.RemoveBike(this); rentPoint.AddBike(this); RentPoint = rentPoint; }
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; }