예제 #1
0
        private IQueryable <Player> FilterPlayers(IQueryable <Player> query, PlayerFilter filter)
        {
            if (filter != null)
            {
                if (filter.Id != 0)
                {
                    query = query.Where(m => m.Id == filter.Id);
                }

                if (!String.IsNullOrEmpty(filter.Name))
                {
                    query = query.Where(m => m.Name.Contains(filter.Name));
                }

                if (filter.Archived != null)
                {
                    query = query.Where(m => m.Archived == filter.Archived);
                }
            }

            return(query);
        }
예제 #2
0
 public async Task <IEnumerable <Player> > GetAllWithFilter(PlayerFilter filter)
 {
     return(await FilterPlayers(db.Players, filter).OrderBy(p => p.Name).ToListAsync());
 }