コード例 #1
0
 public async Task <IActionResult> Search([FromQuery] ItemTypeSearchRequest request)
 {
     return(await FunctionWrapper.ExecuteFunction(this, async() =>
     {
         return await _itemTypeRepository.Search(request);
     }));
 }
コード例 #2
0
        public async Task<List<ItemType>> Search(ItemTypeSearchRequest request)
        {
            List<FilterDefinition<ItemType>> filters = new List<FilterDefinition<ItemType>>();
            if (!string.IsNullOrEmpty(request.Name))
                filters.Add(Builders<ItemType>.Filter.Eq("Name", request.Name));
            if (request.IsForPysicalItems != null)
                filters.Add(Builders<ItemType>.Filter.Eq("IsForPysicalItems", request.IsForPysicalItems));
            if (request.AllowNestedItems != null)
                filters.Add(Builders<ItemType>.Filter.Eq("AllowNestedItems", request.AllowNestedItems));

            try
            {
                var filterConcat = Builders<ItemType>.Filter.And(filters);
                return await _context.ItemTypes.Find(filterConcat).ToListAsync();
            }
            catch (Exception ex)
            {
                //TODO: log/manage exception
                throw ex;
            }
        }