コード例 #1
0
        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();
        }
コード例 #2
0
        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();
        }