Beispiel #1
0
        public static IQueryable <Employee> AplyFilter(this IQueryable <Employee> query, FilterDto filter)
        {
            if (filter != null)
            {
                if (!string.IsNullOrEmpty(filter.Name))
                {
                    query = query.Where(n => n.FullName.FirstName.Contains(filter.Name) || n.FullName.LastName.Contains(filter.Name));
                }

                if (filter.Age != 0)
                {
                    query = query.Where(i => AgeUtil.Age(i.BirthDate) == filter.Age);
                }

                if (filter.Gender != 0)
                {
                    query = query.Where(g => (int)g.Gender == filter.Gender);
                }
            }

            return(query);
        }
Beispiel #2
0
        private static bool IsOverEighteen(DateTime birthDate)
        {
            var age = AgeUtil.Age(birthDate) > 18;

            return(age);
        }