Ejemplo n.º 1
0
        public static int deleteDogFromReservation(int reservationNumber, int petNumber)
        {
            Search search = new HawkeyehvkBLL.Search();

            if (!search.validateReservationNumber(reservationNumber))// check reservation number
            {
                return(1);
            }
            else if (!search.validatePetNumber(petNumber))// check pet number
            {
                return(2);
            }
            else if (!ReservationDB.isDogInReservation(reservationNumber, petNumber))// check that dog is in reservation
            {
                return(3);
            }
            else if (isReservationActive(reservationNumber))//check is res is active
            {
                return(4);
            }
            else
            {
                // before running check if the reservation is going from 3 to 2 dogs in order to remove the discount
                int count = PetReservation.listPetRes(reservationNumber).Count;
                if (count == 3)
                {
                    Discount.deleteReservationDiscount(2, reservationNumber);
                }
                return(ReservationDB.deleteDogFromReservationDB(reservationNumber, petNumber));
            }
        }
Ejemplo n.º 2
0
        public static int cancelReservation(int reservationNumber)
        {
            Search search = new HawkeyehvkBLL.Search();

            // check reservation number
            if (!search.validateReservationNumber(reservationNumber))// check reservation number
            {
                return(1);
            }
            else if (isReservationActive(reservationNumber))
            {
                return(4);
            }
            else
            {
                return(ReservationDB.cancelReservationDB(reservationNumber));
            }
        }
Ejemplo n.º 3
0
        public static int changeReservation(int reservationNumber, DateTime startDate, DateTime endDate)
        {
            Search search = new HawkeyehvkBLL.Search();

            if (!search.validateReservationNumber(reservationNumber))// check reservation number
            {
                return(1);
            }
            else if (startDate > endDate)     // check that dates are in a valid order
            {
                return(2);
            }
            List <Pet> pets      = Pet.listPetsByReservation(reservationNumber);
            int        largeDogs = 0;

            foreach (Pet pet in pets)
            {
                if (pet.size == 'L')
                {
                    largeDogs++;
                }
            }
            // check that there are available runs

            if (Run.checkRunAvailability(startDate, endDate, 'L') < largeDogs ||
                Run.checkRunAvailability(startDate, endDate, 'R') < pets.Count)
            {
                return(3);
            }
            // change the res dates
            try
            {
                ReservationDB db = new ReservationDB();
                db.changeReservationDB(reservationNumber, startDate, endDate);
            } catch
            {
                return(4);
            }
            return(0);
        }