Example #1
0
        public async Task <List <CategoryViewModel> > GetAllCategoryAsync(CategoryRequestGetAllModel categoryRequestGetAllModel)
        {
            var list = await GetAll()
                       .Where(x => (!categoryRequestGetAllModel.IsActive.HasValue || x.RecordActive == categoryRequestGetAllModel.IsActive) &&
                              (string.IsNullOrEmpty(categoryRequestGetAllModel.Query) ||
                               (x.Name.Contains(categoryRequestGetAllModel.Query)
                               )))
                       .Select(x => new CategoryViewModel(x)).ToListAsync();

            return(list);
        }
Example #2
0
        public async Task <IActionResult> GetAllCategories(CategoryRequestGetAllModel categoryRequestGetAllModel)
        {
            var category = await _categoryService.GetAllCategoryAsync(categoryRequestGetAllModel);

            return(Ok(category));
        }