Exemplo n.º 1
0
        public async Task <IActionResult> GetCategoryAsync(FillterCategory fillterCategory)
        {
            var categorySoruce = await _context.Categorys.ToListAsync();

            var categorys = _mapper.Map <IEnumerable <Category>, IEnumerable <CategoryDTO> >(categorySoruce);

            if (fillterCategory.Name != "")
            {
                categorys = categorys.Where(c => c.Name.ToLower().Contains(fillterCategory.Name.ToLower())).ToList();
            }
            return(Ok(new { success = true, data = categorys }));
        }
        public async Task <IActionResult> GetAll([FromQuery] FillterCategory fillterCategory)
        {
            var result = await _categoryService.GetCategoryAsync(fillterCategory);

            return(result);
        }