public async Task UpdatePetInFamilyAsync(string streetName, int houseNumber, Pet pet)
        {
            if (!families.Any())
            {
                families = await GetAllFamiliesAsync();
            }

            foreach (var family in families)
            {
                if (family.StreetName.Equals(streetName) && family.HouseNumber == houseNumber)
                {
                    family.EditPet(pet);
                }
            }
            await WriteFamiliesToFile();
        }
        public async Task AddPetToFamilyAsync(string streetName, int houseNumber, Pet pet)
        {
            if (!families.Any())
            {
                families = await GetAllFamiliesAsync();
            }

            foreach (var family in families)
            {
                if (family.StreetName.Equals(streetName) && family.HouseNumber == houseNumber)
                {
                    pet.Id = ++lastPetId;
                    family.AddPet(pet);
                }
            }
            await WriteFamiliesToFile();
        }
Exemplo n.º 3
0
 public void AddPet(Pet pet)
 {
     Pets.Add(pet);
     Console.WriteLine("\t\tSuccessfully added pet");
 }