public async Task AddChildToFamilyAsync(string streetName, int houseNumber, Child child) { if (!families.Any()) { families = await GetAllFamiliesAsync(); } foreach (var family in families) { if (family.StreetName.Equals(streetName) && family.HouseNumber == houseNumber) { child.Id = ++lastChildId; family.AddPerson(child, "Child"); } } await WriteFamiliesToFile(); }
public async Task UpdateChildInFamilyAsync(string streetName, int houseNumber, Child child) { if (!families.Any()) { families = await GetAllFamiliesAsync(); } foreach (var family in families) { if (family.StreetName.Equals(streetName) && family.HouseNumber == houseNumber) { family.EditChild(child); } } await WriteFamiliesToFile(); }