Example #1
0
        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);
            }
        }
Example #2
0
        protected internal void LockOnRentPoint(RentPoint rentPoint)
        {
            if (rentPoint == null)
            {
                throw new ArgumentNullException(nameof(rentPoint));
            }

            RentPoint = rentPoint;
        }
Example #3
0
        protected internal void Return(RentPoint rentPoint)
        {
            if (IsFree)
            {
                throw new InvalidOperationException("Bike is free");
            }

            RentPoint = rentPoint;
        }
Example #4
0
        protected internal void Take()
        {
            if (!IsFree)
            {
                throw new InvalidOperationException("Bike is not free");
            }

            RentPoint = null;
        }
Example #5
0
        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);
        }
Example #6
0
        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);
        }
Example #7
0
        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;
        }
Example #8
0
        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;
        }