| 123456789101112131415161718192021222324252627282930313233343536 |
- using Microsoft.AspNetCore.Mvc;
-
- namespace Diligent.WebAPI.Host.Controllers.V1
- {
- [ApiVersion("1.0")]
- [Route("v{version:apiVersion}/categories")]
- [ApiController]
- public class CategoriesController : ControllerBase
- {
- private readonly ICategoryService _categoryService;
-
- public CategoriesController(ICategoryService categoryService)
- {
- _categoryService = categoryService;
- }
-
- [HttpGet("root-categories/{parentCategoryId:int?}")]
- public async Task<IActionResult> GetRootCategories(int parentCategoryId = -1)
- {
- User? user = (User?)HttpContext.Items["User"];
- return Ok(await _categoryService.GetRootCategories(user.Id,parentCategoryId));
- }
-
- [HttpGet("granted-categories")]
- public async Task<IActionResult> GetCategories(int userId) =>
- Ok(await _categoryService.GetCategories(userId));
-
- [HttpGet("all-categories")]
- public async Task<IActionResult> GetAllCategories()
- {
- User? user = (User?)HttpContext.Items["User"];
- return Ok(await _categoryService.GetAllCategories(user.Id));
- }
-
- }
- }
|