Ejemplo n.º 1
0
        public void RemoveAdult(int FamilyId, int AdultId)
        {
            Family familyFromToRemove = Families.First(f => f.Id == FamilyId);
            Adult  adultToRemove      = familyFromToRemove.Adults.First(a => a.Id == AdultId);

            int familyIndex = Families.IndexOf(familyFromToRemove);

            Families[familyIndex].Adults.Remove(adultToRemove);

            SaveChanges();
        }
        public void TryUpdateFamily(Rock.Client.Family family)
        {
            // see if the family exists
            Rock.Client.Family currFamily = Families.Where(f => f.Id == family.Id).SingleOrDefault( );

            // if it does, get its index and replace it.
            if (currFamily != null)
            {
                int currIndex = Families.IndexOf(currFamily);
                Families[currIndex] = family;
            }
        }
Ejemplo n.º 3
0
        public void AddAdult(Adult adult, Family family)
        {
            int currentFamily = Families.IndexOf(family);


            int max = Adults.Max(adult => adult.Id);

            adult.Id = (++max);

            Families.ElementAt(currentFamily).Adults.Add(adult);
            Adults.Add(adult);
            SaveChanges();
        }
Ejemplo n.º 4
0
        public async void Update(int familyId)
        {
            var sourceFamily = await _apiClient.Families_GetAsync(familyId);

            var orphansCountTask = _apiClient.Families_GetOrphansCountAsync(familyId);
            //update father object in the source list
            var sourceFamilyIndex = _SourceFamilies.IndexOf(_SourceFamilies.FirstOrDefault(f => f.Id == familyId));

            _SourceFamilies[sourceFamilyIndex] = sourceFamily;

            var familyModel       = _mapperService.MapToFamilyModel(sourceFamily);
            var FamilyToEdit      = Families.FirstOrDefault(c => c.Id == familyId);
            var FamilyToEditIndex = Families.IndexOf(FamilyToEdit);

            familyModel.OrphansCount    = await orphansCountTask;
            Families[FamilyToEditIndex] = familyModel;
        }