예제 #1
0
        /// <summary>
        /// Zählt die Personen in der Datenbank
        /// </summary>
        /// <param name="type">Filterung nach Zähltyp</param>
        /// <param name="countFullAged">Filterung nach volljährigen Personen</param>
        /// <returns>Die Anzahl der Personen in der Datenbank</returns>
        public static int Count(CountStateType type = CountStateType.All, bool countFullAged = false)
        {
            using (TafelModelContainer db = new TafelModelContainer())
            {
                var persons = db.Persons.AsQueryable();

                switch (type)
                {
                case CountStateType.Activated:
                    persons = persons.Where(p => p.IsActive);
                    break;

                case CountStateType.Deactivated:
                    persons = persons.Where(p => !p.IsActive);
                    break;
                }

                var personCountList = persons.ToList();
                if (countFullAged)
                {
                    personCountList = personCountList.Where(p => p.Age >= 18).ToList();
                }

                return(personCountList.Count());
            }
        }
예제 #2
0
        /// <summary>
        /// Zählt die Teammitglieder in der Datenbank
        /// </summary>
        /// <param name="type">Filterung nach Typ</param>
        /// <returns>Die Anzahl der Teammitglieder in der Datenbank</returns>
        public static int Count(CountStateType type = CountStateType.All)
        {
            using (TafelModelContainer db = new TafelModelContainer())
            {
                var teams = db.Teams.AsQueryable();

                if (type != CountStateType.All)
                {
                    bool activateState = (type == CountStateType.Activated) ? true : false;
                    teams = teams.Where(t => t.IsActive == activateState);
                }

                return(teams.Count());
            }
        }
예제 #3
0
        /// <summary>
        /// Zählt Sponsoren in der Datenbank
        /// </summary>
        /// <param name="type">Filterung nach Typ</param>
        /// <returns>Anzahl der gezählten Sponsoren</returns>
        public static int Count(CountStateType type = CountStateType.All)
        {
            using (TafelModelContainer db = new TafelModelContainer())
            {
                var sponsors = db.Sponsors.AsQueryable();

                switch (type)
                {
                case CountStateType.Activated:
                    sponsors = sponsors.Where(s => s.IsActive);
                    break;

                case CountStateType.Deactivated:
                    sponsors = sponsors.Where(s => !s.IsActive);
                    break;
                }

                return(sponsors.Count());
            }
        }
예제 #4
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();
            }
        }
예제 #5
0
        /// <summary>
        /// Zählt Sponsoren in der Datenbank
        /// </summary>
        /// <param name="type">Filterung nach Typ</param>
        /// <returns>Anzahl der gezählten Sponsoren</returns>
        public static int Count(CountStateType type = CountStateType.All)
        {
            using (TafelModelContainer db = new TafelModelContainer())
            {
                var sponsors = db.Sponsors.AsQueryable();

                switch (type)
                {
                    case CountStateType.Activated:
                        sponsors = sponsors.Where(s => s.IsActive);
                        break;

                    case CountStateType.Deactivated:
                        sponsors = sponsors.Where(s => !s.IsActive);
                        break;
                }

                return sponsors.Count();
            }
        }
예제 #6
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());
            }
        }
예제 #7
0
        /// <summary>
        /// Zählt die Teammitglieder in der Datenbank
        /// </summary>
        /// <param name="type">Filterung nach Typ</param>
        /// <returns>Die Anzahl der Teammitglieder in der Datenbank</returns>
        public static int Count(CountStateType type = CountStateType.All)
        {
            using (TafelModelContainer db = new TafelModelContainer())
            {
                var teams = db.Teams.AsQueryable();

                if (type != CountStateType.All)
                {
                    bool activateState = (type == CountStateType.Activated) ? true : false;
                    teams = teams.Where(t => t.IsActive == activateState);
                }

                return teams.Count();
            }
        }
예제 #8
0
        /// <summary>
        /// Zählt die Personen in der Datenbank
        /// </summary>
        /// <param name="type">Filterung nach Zähltyp</param>
        /// <param name="countFullAged">Filterung nach volljährigen Personen</param>
        /// <returns>Die Anzahl der Personen in der Datenbank</returns>
        public static int Count(CountStateType type = CountStateType.All, bool countFullAged = false)
        {
            using (TafelModelContainer db = new TafelModelContainer())
            {
                var persons = db.Persons.AsQueryable();

                switch (type)
                {
                    case CountStateType.Activated:
                        persons = persons.Where(p => p.IsActive);
                        break;

                    case CountStateType.Deactivated:
                        persons = persons.Where(p => !p.IsActive);
                        break;
                }

                var personCountList = persons.ToList();
                if (countFullAged)
                {
                    personCountList = personCountList.Where(p => p.Age >= 18).ToList();
                }

                return personCountList.Count();
            }
        }