예제 #1
0
 public IActionResult Get([FromQuery] CategorySearch search, [FromServices] IGetCategoriesQuery query)
 {
     return(Ok(executor.ExecuteQuery(query, search)));
 }
예제 #2
0
        public Task <IEnumerable <Category> > GetAsync(
            CategorySearch option,
            CancellationToken token = default(CancellationToken))
        {
            string query = @"
SELECT      ct.*
          , ac.Code [AccountTitleCode] , ac.Name [AccountTitleName]
          , pa.Code [PaymentAgencyCode], pa.Name [PaymentAgencyName]
          , tc.Name [TaxClassName]
FROM        Category ct
LEFT JOIN   AccountTitle ac     ON ac.Id        = ct.AccountTitleId
LEFT JOIN   PaymentAgency pa    ON pa.Id        = ct.PaymentAgencyId
LEFT JOIN   TaxClass tc         ON tc.Id        = ct.TaxClassId
WHERE       ct.Id                   = ct.Id";

            if (option.CompanyId.HasValue)
            {
                query += @"
AND         ct.CompanyId            = @CompanyId";
            }
            if (option.CategoryType.HasValue)
            {
                query += @"
AND         ct.CategoryType         = @CategoryType";
            }
            if (option.UseInput.HasValue)
            {
                query += @"
AND         ct.UseInput             = @UseInput";
            }
            if (option.UseLimitDate.HasValue)
            {
                query += @"
AND         ct.UseLimitDate         = @UseLimitDate";
            }
            if (option.UseAccountTransfer.HasValue)
            {
                query += @"
AND         ct.UseAccountTransfer   = @UseAccountTransfer";
            }
            if (!string.IsNullOrWhiteSpace(option.Name))
            {
                option.Name = Sql.GetWrappedValue(option.Name);
                query      += @"
AND         ct.Name                 LIKE @Name";
            }
            if (option.Ids?.Any() ?? false)
            {
                query += @"
AND         ct.Id                   IN (SELECT Id   FROM @Ids)";
            }
            if (option.Codes?.Any() ?? false)
            {
                query += @"
AND         ct.Code                 IN (SELECT Code FROM @Codes)";
            }
            query += @"
ORDER BY    ct.CompanyId            ASC
          , ct.CategoryType         ASC
          , ct.Code                 ASC";
            return(dbHelper.GetItemsAsync <Category>(query, new {
                option.CompanyId,
                option.CategoryType,
                option.UseInput,
                option.UseLimitDate,
                option.UseAccountTransfer,
                option.Name,
                Ids = option.Ids.GetTableParameter(),
                Codes = option.Codes.GetTableParameter(),
            }, token));
        }
        public ActionResult Index(CategorySearch model)
        {
            var response = _listCategoryCommand.Execute(model);

            return(View(response));
        }
        public ActionResult <IEnumerable <CategoryDto> > Get([FromQuery] CategorySearch search)
        {
            var categories = _getCommand.Execute(search);

            return(Ok(categories));
        }
예제 #5
0
        public IActionResult CategoryList(CategorySearch search)
        {
            var result = _articleService.GetCategoryList(search);

            return(Ok(OperateResult.Succeed("ok", result)));
        }