コード例 #1
0
 public async Task <IActionResult> Search([FromQuery] ProjectReleaseSearchRequest searchRequest)
 {
     return(await FunctionWrapper.ExecuteFunction(this, async() =>
     {
         return await _projectRepository.Search(searchRequest);
     }));
 }
コード例 #2
0
        public async Task <IEnumerable <ProjectRelease> > Search(ProjectReleaseSearchRequest searchRequest)
        {
            try
            {
                List <FilterDefinition <ProjectRelease> > filters = new List <FilterDefinition <ProjectRelease> >();

                if (!string.IsNullOrEmpty(searchRequest.ProjectId))
                {
                    filters.Add(Builders <ProjectRelease> .Filter.Eq("ProjectId", new ObjectId(searchRequest.ProjectId)));
                }

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

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

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