Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

CategoriesController.cs 929B

12345678910111213141516171819202122232425262728
  1. using Microsoft.AspNetCore.Mvc;
  2. namespace Diligent.WebAPI.Host.Controllers.V1
  3. {
  4. [ApiVersion("1.0")]
  5. [Route("v{version:apiVersion}/categories")]
  6. [ApiController]
  7. public class CategoriesController : ControllerBase
  8. {
  9. private readonly ICategoryService _categoryService;
  10. public CategoriesController(ICategoryService categoryService)
  11. {
  12. _categoryService = categoryService;
  13. }
  14. [HttpGet("root-categories/{parentCategoryId:int?}")]
  15. public async Task<IActionResult> GetRootCategories(int parentCategoryId = -1)
  16. {
  17. User? user = (User?)HttpContext.Items["User"];
  18. return Ok(await _categoryService.GetRootCategories(8,parentCategoryId));
  19. }
  20. [HttpGet("granted-categories")]
  21. public async Task<IActionResult> GetCategories(int userId) =>
  22. Ok(await _categoryService.GetCategories(userId));
  23. }
  24. }