Esempio n. 1
0
        private void loadFullLists()
        {
            int resNum = Convert.ToInt16(Session["RESERVATION_NUMBER"]);

            Reservation    res = new Reservation();
            Reservation    r   = res.ListReservations().Find(rr => rr.number == resNum);
            Pet            p   = new Pet();
            Service        ser = new Service();
            PetReservation pr  = new PetReservation();

            List <Pet> pets = p.listPets(Convert.ToInt16(r.ownerNumber));

            testSerNewFill(pets, r, pr.ListPetReservations(), ser.ListServices());

            txtStartDate.Text    = r.sDate.ToString("MMM/dd/yyyy");
            txtEndDate.Text      = r.eDate.ToString("MMM/dd/yyyy");
            ddlPickOwner.Visible = false;
        }
Esempio n. 2
0
        protected void btnUpdateReservation_Click(object sender, EventArgs e)
        {
            Pet            p  = new Pet();
            Service        s  = new Service();
            PetReservation pr = new PetReservation();
            Reservation    r  = new Reservation();

            int resNumber = Convert.ToInt16(Session["RESERVATION_NUMBER"]);

            Reservation curr = r.ListReservations().Find(rr => rr.number == resNumber);
            List <Pet>  pets = p.listPets((int)curr.ownerNumber);

            List <PetReservation> petRes = pr.ListPetReservations().FindAll(pr2 => pr2.reservationNum == resNumber);
            List <Service>        prs    = s.ListServices().FindAll(ss => petRes.Any(pr2 => pr2.petResNum == s.petResNumber));

            r.ChangeReservation(curr.number, DateTime.Parse(txtStartDate.Text), DateTime.Parse(txtEndDate.Text));

            int currPet = 0;

            for (int x = 0; x < pets.Count; x++)
            {
                PetReservation thisPetRes  = petRes.Find(pr2 => pr2.petNum == pets[x].number);
                List <Service> thisSerList = thisPetRes != null?s.ListServices().FindAll(prs2 => prs2.petResNumber == thisPetRes.petResNum) : null;

                switch (currPet)
                {
                case 0: {
                    Pet p2 = pets.Find(pp => pp.name == pet1.PetName && pp.ownerNumber == curr.ownerNumber);
                    if (p2 != null)
                    {
                        if (thisPetRes != null)
                        {
                            if (pet1.Included == false)
                            {
                                pr.RemovePetFromRes(p2.number, resNumber);
                            }
                            else
                            {
                                if (thisSerList.Any(q => q.number == 2))
                                {
                                    if (!pet1.Walking)
                                    {
                                        s.DeleteServ(thisPetRes.petResNum, 2);
                                    }
                                }
                                else
                                {
                                    if (pet1.Walking)
                                    {
                                        s.Add(thisPetRes.petResNum, 2);
                                    }
                                }

                                if (thisSerList.Any(q => q.number == 5))
                                {
                                    if (!pet1.Playtime)
                                    {
                                        s.DeleteServ(thisPetRes.petResNum, 5);
                                    }
                                }
                                else
                                {
                                    if (pet1.Playtime)
                                    {
                                        s.Add(thisPetRes.petResNum, 5);
                                    }
                                }
                            }
                        }
                        else
                        {
                            if (pet1.Included)
                            {
                                int petResNum = pr.Add(p2.number, resNumber)[1];
                                s.Add(petResNum, 1);
                                if (pet1.Walking)
                                {
                                    s.Add(petResNum, 2);
                                }
                                if (pet1.Playtime)
                                {
                                    s.Add(petResNum, 5);
                                }
                            }
                        }
                    }
                }
                break;

                case 1: {
                    Pet p2 = pets.Find(pp => pp.name == pet2.PetName && pp.ownerNumber == curr.ownerNumber);
                    if (p2 != null)
                    {
                        if (thisPetRes != null)
                        {
                            if (pet2.Included == false)
                            {
                                pr.RemovePetFromRes(p2.number, resNumber);
                            }
                            else
                            {
                                if (thisSerList.Any(q => q.number == 2))
                                {
                                    if (!pet2.Walking)
                                    {
                                        s.DeleteServ(thisPetRes.petResNum, 2);
                                    }
                                }
                                else
                                {
                                    if (pet2.Walking)
                                    {
                                        s.Add(thisPetRes.petResNum, 2);
                                    }
                                }

                                if (thisSerList.Any(q => q.number == 5))
                                {
                                    if (!pet2.Playtime)
                                    {
                                        s.DeleteServ(thisPetRes.petResNum, 5);
                                    }
                                }
                                else
                                {
                                    if (pet2.Playtime)
                                    {
                                        s.Add(thisPetRes.petResNum, 5);
                                    }
                                }
                            }
                        }
                        else
                        {
                            int petResNum = pr.Add(p2.number, resNumber)[1];
                            s.Add(petResNum, 1);
                            if (pet2.Walking)
                            {
                                s.Add(petResNum, 2);
                            }
                            if (pet2.Playtime)
                            {
                                s.Add(petResNum, 5);
                            }
                        }
                    }
                }
                break;

                case 2: {
                    Pet p2 = pets.Find(pp => pp.name == pet3.PetName && pp.ownerNumber == curr.ownerNumber);
                    if (p2 != null)
                    {
                        if (thisPetRes != null)
                        {
                            if (pet3.Included == false)
                            {
                                pr.RemovePetFromRes(p2.number, resNumber);
                            }
                            else
                            {
                                if (thisSerList.Any(q => q.number == 2))
                                {
                                    if (!pet3.Walking)
                                    {
                                        s.DeleteServ(thisPetRes.petResNum, 2);
                                    }
                                }
                                else
                                {
                                    if (pet3.Walking)
                                    {
                                        s.Add(thisPetRes.petResNum, 2);
                                    }
                                }

                                if (thisSerList.Any(q => q.number == 5))
                                {
                                    if (!pet3.Playtime)
                                    {
                                        s.DeleteServ(thisPetRes.petResNum, 5);
                                    }
                                }
                                else
                                {
                                    if (pet3.Playtime)
                                    {
                                        s.Add(thisPetRes.petResNum, 5);
                                    }
                                }
                            }
                        }
                        else
                        {
                            int petResNum = pr.Add(p2.number, resNumber)[1];
                            s.Add(petResNum, 1);
                            if (pet3.Walking)
                            {
                                s.Add(petResNum, 2);
                            }
                            if (pet3.Playtime)
                            {
                                s.Add(petResNum, 5);
                            }
                        }
                    }
                }
                break;

                case 3: {
                    Pet p2 = pets.Find(pp => pp.name == pet4.PetName && pp.ownerNumber == curr.ownerNumber);
                    if (p2 != null)
                    {
                        if (thisPetRes != null)
                        {
                            if (pet4.Included == false)
                            {
                                pr.RemovePetFromRes(p2.number, resNumber);
                            }
                            else
                            {
                                if (thisSerList.Any(q => q.number == 2))
                                {
                                    if (!pet4.Walking)
                                    {
                                        s.DeleteServ(thisPetRes.petResNum, 2);
                                    }
                                }
                                else
                                {
                                    if (pet4.Walking)
                                    {
                                        s.Add(thisPetRes.petResNum, 2);
                                    }
                                }

                                if (thisSerList.Any(q => q.number == 5))
                                {
                                    if (!pet4.Playtime)
                                    {
                                        s.DeleteServ(thisPetRes.petResNum, 5);
                                    }
                                }
                                else
                                {
                                    if (pet4.Playtime)
                                    {
                                        s.Add(thisPetRes.petResNum, 5);
                                    }
                                }
                            }
                        }
                        else
                        {
                            int petResNum = pr.Add(p2.number, resNumber)[1];
                            s.Add(petResNum, 1);
                            if (pet4.Walking)
                            {
                                s.Add(petResNum, 2);
                            }
                            if (pet4.Playtime)
                            {
                                s.Add(petResNum, 5);
                            }
                        }
                    }
                }
                break;
                }

                if (resNumber < 0)
                {
                    Errors.Add("The reservation could not be added.");
                    break;
                }
                currPet++;
            }
        }