Exemplo n.º 1
0
        public BikeRentResult RentBikeBy(Client client, BikeId bikeId)
        {
            var matchingBike = AvailableBikes.FirstOrDefault(x => x.Id.Equals(bikeId));

            if (matchingBike == null)
            {
                return(new BikeRentResult(new TriedToRentInvalidBike()));
            }
            if (AvailableBikes.Count == 0)
            {
                return(new BikeRentResult((BikeRent)null));
            }

            if (matchingBike.IsBroken)
            {
                return(new BikeRentResult(new BikeBroken()));
            }
            if (client.ActivesBikes >= 2)
            {
                return(new BikeRentResult(new RentLimitExceeded()));
            }
            if (client.Funds().IsGreaterThanOrEqual(10.00m))
            {
                AvailableBikes.Remove(matchingBike);
                return(new BikeRentResult(new BikeRent()));
            }



            return(new BikeRentResult((BikeRent)null));
        }
Exemplo n.º 2
0
 public Bike()
 {
     Id = new BikeId(Guid.NewGuid());
 }
Exemplo n.º 3
0
 public Bike(BikeId id)
 {
     Id = id;
 }