Exemplo n.º 1
0
        public List <PetReservation> ListPetReservations()
        {
            PetReservationDB prDB = new PetReservationDB();
            DataTable        data = prDB.GetFullPetResInfo();

            return(GetPetReservations(data));
        }
Exemplo n.º 2
0
        public e Update(int petResNumber, int petNumber, int reservationNumber)
        {
            e errCode             = e.success;
            PetReservationDB prDB = new PetReservationDB();

            if (!prDB.Update(petResNumber, petNumber, reservationNumber))
            {
                errCode = e.updateFail;
            }
            return(errCode);
        }
Exemplo n.º 3
0
        public e RemovePetFromRes(int petNumber, int resNumber)
        {
            e errCode             = e.success;
            PetReservationDB prDB = new PetReservationDB();
            Service          ser  = new Service();

            ser.Delete(ListPetReservations().Find(pr => pr.petNum == petNumber && pr.reservationNum == resNumber).petResNum);
            if (!prDB.RemovePetFromRes(petNumber, resNumber))
            {
                errCode = e.deleteFail;
            }
            return(errCode);
        }
Exemplo n.º 4
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));
        }
Exemplo n.º 5
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);
        }
Exemplo n.º 6
0
        public static List <PetReservation> listPetRes(int ReservationNumber)
        {
            PetReservationDB pres = new PetReservationDB();

            List <PetReservation> list = new List <PetReservation>();

            foreach (DataRow row in pres.listPetResDB(ReservationNumber).Tables["hvk_pet_reservation"].Rows)
            {
                PetReservation petRes = new PetReservation();
                try
                {
                    petRes.petResNumber = Convert.ToInt32(row["reservation_number"].ToString());
                    petRes.pet          = Pet.getOnePet(Convert.ToInt32(row["PET_PET_NUMBER"]));
                }
                catch (Exception e) {
                    Console.Write(e);
                }
            }

            return(list);
        }
Exemplo n.º 7
0
        public e RemoveEntireRes(int resNumber)
        {
            e errCode             = e.success;
            PetReservationDB prDB = new PetReservationDB();
            Service          serv = new Service();

            foreach (PetReservation pr in ListPetReservations().Where(r => r.reservationNum == resNumber))
            {
                if (serv.Delete(pr.petResNum) < 0)
                {
                    errCode = e.deleteFail;
                }
            }

            if (!prDB.RemoveEntireRes(resNumber))
            {
                errCode = e.deleteFail;
            }

            return(errCode);
        }