Esempio n. 1
0
        /// <summary>
        /// Zählt bestehende Kinder in der Datenbank
        /// </summary>
        /// <param name="childGenderType">Typ nach welchen welchen Kindern gefiltert werden soll</param>
        /// <param name="parentCountState">Typ nach welchen welchen Eltern gefiltert werden soll</param>
        /// <returns>Anzahl von Kindern in der Datenbank</returns>
        public static int Count(CountChildGenderType childGenderType = CountChildGenderType.All, CountStateType parentCountState = CountStateType.All)
        {
            using (TafelModelContainer db = new TafelModelContainer())
            {
                var children = db.Children.AsQueryable();

                // Eltern filter
                if (parentCountState != CountStateType.All)
                {
                    bool activateState = (parentCountState == CountStateType.Activated) ? true : false;
                    children = children.Where(p => p.Person.IsActive == activateState);
                }
                if (childGenderType != CountChildGenderType.All)
                {
                    bool isFemale = (childGenderType == CountChildGenderType.Female) ? true : false;
                    children = children.Where(c => c.IsFemale == isFemale);
                }

                return(children.Count());
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Zählt bestehende Kinder in der Datenbank
        /// </summary>
        /// <param name="childGenderType">Typ nach welchen welchen Kindern gefiltert werden soll</param>
        /// <param name="parentCountState">Typ nach welchen welchen Eltern gefiltert werden soll</param>
        /// <returns>Anzahl von Kindern in der Datenbank</returns>
        public static int Count(CountChildGenderType childGenderType = CountChildGenderType.All, CountStateType parentCountState = CountStateType.All)
        {
            using (TafelModelContainer db = new TafelModelContainer())
            {
                var children = db.Children.AsQueryable();

                // Eltern filter
                if (parentCountState != CountStateType.All)
                {
                    bool activateState = (parentCountState == CountStateType.Activated) ? true : false;
                    children = children.Where(p => p.Person.IsActive == activateState);
                }
                if (childGenderType != CountChildGenderType.All)
                {
                    bool isFemale = (childGenderType == CountChildGenderType.Female) ? true : false;
                    children = children.Where(c => c.IsFemale == isFemale);
                }

                return children.Count();
            }
        }