public async Task <Quest[]> GetAll(QueryAllFilter queryFilter) { var filter = Builders <Quest> .Filter; var filterList = new List <FilterDefinition <Quest> >(); if (queryFilter.MinReward != null) { filterList.Add(filter.Gte(quest => quest.Reward, queryFilter.MinReward)); } if (queryFilter.Status != null) { filterList.Add(filter.Eq(quest => quest.Status, queryFilter.Status)); } if (queryFilter.Poster != null) { Console.WriteLine($"POSTER FILTER {queryFilter.Poster}"); filterList.Add(filter.Eq(quest => quest.Poster, queryFilter.Poster)); } List <Quest> resultList; if (filterList.Count > 0) { resultList = await collection.Find(filter.And(filterList.ToArray())).ToListAsync(); } else { resultList = await collection.Find(new BsonDocument()).ToListAsync(); } return(resultList.ToArray()); }
public async Task <Quest[]> GetAll([FromQuery] QueryAllFilter filter) { return(await repository.GetAll(filter)); }