Esempio 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));
            }
        }
Esempio n. 2
0
 public bool addPetReservation(PetReservation petRes)
 {
     this.petReservationList.Add(petRes);
     if (!petRes.pet.Equals(this))
     {
         petRes.pet = this;
     }
     return(true);
 }
Esempio n. 3
0
        public static int addToReservation(int reservationNumber, int petNumber)
        {
            ReservationDB db     = new ReservationDB();
            Search        search = new Search();

            try
            {
                if (!search.validatePetNumber(petNumber))
                {
                    return(-1);
                }
                else if (!search.validateReservationNumber(reservationNumber))
                {
                    return(-2);
                }
                else if (Search.validateOwnerForPet(reservationNumber, petNumber) < 0)
                {
                    return(-4);
                }
                else if (search.validateReservationForPet(petNumber, reservationNumber))
                {
                    return(-3);
                }


                // add discount if we are adding a third pet reservation
                int count = PetReservation.listPetRes(reservationNumber).Count;
                if (count == 2)
                {
                    Discount.addReservationDiscount(2, reservationNumber);
                }

                db.addToReservationDB(reservationNumber, petNumber);
                return(1);
            }
            catch
            {
                //Exception msg goes here
                return(-4);
            }
        }
Esempio n. 4
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);
        }
Esempio n. 5
0
 public bool removePetReservation(PetReservation petRes)
 {
     petRes.pet = new Pet();
     return(this.petReservationList.Remove(petRes));
 }
Esempio n. 6
0
 public bool removePetRes(PetReservation petRes)
 {
     return(this.petResList.Remove(petRes));
 }
Esempio n. 7
0
 public bool addPetRes(PetReservation petRes)
 {
     this.petResList.Add(petRes);
     return(true);
 }