コード例 #1
0
        public BoatRentalOrder orderBoatRental(BoatRental boatRental, PaymentType paymentType, Address orderAddress, User user)
        {
            if (boatRental == null || orderAddress == null || user == null)
            {
                return(null);
            }

            if (!this.users.Contains(user))
            {
                return(null);
            }

            bool     boatFound = false;
            Location location  = null;

            foreach (Location l in this.locations)
            {
                if (l.getBoats().Contains(boatRental.boat))
                {
                    boatFound = true;
                    location  = l;
                    break;
                }
            }
            if (!boatFound)
            {
                return(null);
            }

            if (!location.getBoatRentals().Contains(boatRental))
            {
                return(null);
            }

            BoatRentalOrder boatRentalOrder = new BoatRentalOrder(paymentType, DateTime.Now, user, orderAddress, ++numOrders, boatRental);

            DAL.Order value = boatRentalOrder.saveInDB();

            if (value == null)
            {
                return(null);
            }

            //value.boatToursManagerId = 1;
            entity.numOrders = this.numOrders;
            db.SaveChanges();

            this.orders.Add(boatRentalOrder.orderNumber, boatRentalOrder);
            return(boatRentalOrder);
        }
コード例 #2
0
        public BoatRental rentBoat(Boat boat, DateTime startTime, DateTime endTime, int numPersons)
        {
            if (!this.canRentBoat(boat, startTime, endTime, numPersons))
            {
                return(null);
            }

            BoatRental rental = new BoatRental(startTime, endTime, boat, numPersons);

            if (rental.saveInDB() == null)
            {
                return(null);
            }

            this.boatRentals.Add(rental);
            return(rental);
        }
コード例 #3
0
 public BoatRentalOrder(DAL.Order order) : base(order)
 {
     this.boatRental = new BoatRental(order.BoatRental);
 }
コード例 #4
0
 public BoatRentalOrder(PaymentType paymentType, DateTime orderDate, User user, Address orderAddress,
                        int orderNumber, BoatRental boatRental)
     : base(paymentType, orderDate, user, orderAddress, boatRental.getTotalPrice(), orderNumber)
 {
     this.boatRental = boatRental ?? throw new ArgumentNullException(nameof(boatRental));
 }