예제 #1
0
 public async Task <IActionResult> Search([FromQuery] ProjectSearchRequest searchRequest)
 {
     return(await FunctionWrapper.ExecuteFunction(this, async() =>
     {
         return await _projectRepository.Search(searchRequest);
     }));
 }
예제 #2
0
        public async Task <IEnumerable <Project> > Search(ProjectSearchRequest searchRequest)
        {
            try
            {
                List <FilterDefinition <Project> > filters = new List <FilterDefinition <Project> >();

                if (!string.IsNullOrEmpty(searchRequest.Name))
                {
                    filters.Add(Builders <Project> .Filter.Regex("Name", new BsonRegularExpression($".*{searchRequest.Name}.*")));
                }

                var filterConcat = Builders <Project> .Filter.And(filters);

                return(await _context.Projects.Find(filterConcat).ToListAsync());
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }