コード例 #1
0
ファイル: CategoryService.cs プロジェクト: thanhuchiha/DATN
        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);
        }
コード例 #2
0
        public async Task <IActionResult> GetAllCategories(CategoryRequestGetAllModel categoryRequestGetAllModel)
        {
            var category = await _categoryService.GetAllCategoryAsync(categoryRequestGetAllModel);

            return(Ok(category));
        }