Beispiel #1
0
        private void updateAwlPets(AwlApi api)
        {
            HashSet <Id> found = new HashSet <Id>();

            foreach (AwlPet p in api.data)
            {
                Id id = new Id(ORIGIN, p.unique_id);
                found.Add(id);

                Pet pet = allPets.Get(id);
                if (pet == null)
                {
                    pet = p.Create();
                    allPets.Add(pet);
                }
                else
                {
                    p.Update(pet);
                }
            }

            foreach (Pet pet in allPets.GetAll().Where(p => p.Id.Origin == ORIGIN && !found.Contains(p.Id)))
            {
                pet.Status = Status.Adopted;
            }
        }
Beispiel #2
0
        private void updateRspcaPets(IEnumerable <RspcaPet> api)
        {
            HashSet <Id> found = new HashSet <Id>();

            foreach (RspcaPet p in api.Where(shelterAllowed))
            {
                Id id = new Id(ORIGIN, p.api_id);
                found.Add(id);

                Pet pet = allPets.Get(id);
                if (pet == null)
                {
                    pet = p.Create();
                    allPets.Add(pet);
                }
                else
                {
                    p.Update(pet);
                }
            }

            foreach (Pet pet in allPets.GetAll().Where(p => p.Id.Origin == ORIGIN && !found.Contains(p.Id)))
            {
                pet.Status = Status.Adopted;
            }
        }
Beispiel #3
0
        private IList <Pet> GetFilteredPets()
        {
            Model             m    = (Model)DataContext;
            IEnumerable <Pet> pets = allPets.GetAll();

            if (!m.Cat)
            {
                pets = pets.Where(notCat);
            }
            if (!m.Rabbit)
            {
                pets = pets.Where(notRabbit);
            }
            if (!m.Dog)
            {
                pets = pets.Where(notDog);
            }
            if (!m.Other)
            {
                pets = pets.Where(notOther);
            }
            return(pets.OrderBy(x => x.LastChanged).ThenBy(x => x.Name).ThenBy(x => x.Id).ToList());
        }