Esempio n. 1
0
        //Adds a new dog to an existing reservation
        public int AddToReservation(int reservationNumber, int petNumber)
        {
            e errCode = e.success;

            if (Validation.invalidRes(reservationNumber))
            {
                errCode = e.invalidRes;
            }
            else if (Validation.invalidPet(petNumber))
            {
                errCode = e.invalidPet;
            }
            else if (Validation.differentOwner(petNumber, reservationNumber))
            {
                errCode = e.differentOwner;
            }
            else if (Validation.petInRes(petNumber, reservationNumber))
            {
                errCode = e.petInRes;
            }
            else if (Validation.runUnavailable(petNumber, reservationNumber))
            {
                errCode = e.runUnavailable;
            }
            else
            {
                PetReservationDB resDB = new PetReservationDB();
                if (resDB.Add(petNumber, reservationNumber) < 0)
                {
                    errCode = e.insertFail;
                }
                else
                {
                    if (CheckVaccinations(petNumber, ListReservations().Find(r => r.number == reservationNumber).eDate) != 0)
                    {
                        errCode = e.vaccInvalid;
                    }
                }
            }

            return(Convert.ToInt16(errCode));
        }
Esempio n. 2
0
        public List <int> Add(int petNumber, int reservationNumber)
        {
            e errCode = e.success;

            int        petResNum = -1;
            List <int> retVals   = new List <int>();

            PetReservationDB prDB = new PetReservationDB();

            petResNum = prDB.Add(petNumber, reservationNumber);
            if (petResNum < 0)
            {
                errCode = e.insertFail;
            }

            retVals.Add(Convert.ToInt16(errCode));
            retVals.Add(petResNum);

            return(retVals);
        }