示例#1
0
        public static int addReservation(int petNumber, DateTime startDate, DateTime endDate)
        {
            Search check = new Search();

            //return -10 Invalid Pet Number
            if (check.validatePetNumber(petNumber) == false)
            {
                return(-10);
            }
            //return -11 Start Date In the past
            if (startDate < DateTime.Now)
            {
                return(-11);
            }
            //return -12 Start Date After end date
            if (startDate > endDate)
            {
                return(-12);
            }
            //return -13 Dog has reservation for all or part of period
            if (check.validateConflictingReservations(petNumber, startDate, endDate) == false)
            {
                return(-13);
            }
            //return -14 No Run Available

            if (Run.checkRunAvailability(startDate, endDate, check.getPetSize(petNumber)) <= 0)
            {
                return(-14);
            }
            //return -15 Insert Failed

            ReservationDB reservation = new ReservationDB();

            if (reservation.addReservation(petNumber, startDate, endDate) == -1)
            {
                return(-15);
            }


            //return -1 if expired or missing Vaccinations
            int count = PetVaccination.checkVaccinations(petNumber, endDate);

            if (count == -1)
            {
                return(-1);
            }
            else
            {
                return(0);
            }
        }