using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Authorization;
using DomainResults.Mvc;
using WeatherForecast.Services;
using WeatherForecast.Models.Requests;
namespace WeatherForecast.Controllers;
///
///
///
[Authorize(Policy = "WhitelistToken")]
[ApiController]
[Route("api/[controller]")]
public class CategoryItemController : ControllerBase {
private readonly ICategoryItemService _categoryItemService;
///
///
///
///
public CategoryItemController(
ICategoryItemService categoryItemService) {
_categoryItemService = categoryItemService;
}
///
///
///
///
///
///
[HttpPost("{siteId}")]
public IActionResult Post([FromRoute] Guid siteId, [FromBody] CategoryItemRequestModel requestData) {
var result = _categoryItemService.Post(siteId, requestData);
return result.ToActionResult();
}
///
/// Returns full object
///
///
///
///
[HttpGet("{siteId}/{categoryId}")]
public IActionResult Get([FromRoute] Guid siteId, [FromRoute] Guid categoryId) {
var result = _categoryItemService.Get(siteId, categoryId);
return result.ToActionResult();
}
///
///
///
///
///
[AllowAnonymous]
[HttpGet("{siteId}")]
public IActionResult GetSlug([FromRoute] Guid siteId, [FromQuery] string slug) {
var result = _categoryItemService.GetSlug(siteId, slug);
return result.ToActionResult();
}
///
///
///
///
///
///
///
[HttpPut("{siteId}/{categoryId}")]
public IActionResult Update([FromRoute] Guid siteId, [FromRoute] Guid categoryId, [FromBody] CategoryItemRequestModel requestData) {
var result = _categoryItemService.Update(siteId, categoryId, requestData);
return result.ToActionResult();
}
///
///
///
///
///
///
[HttpDelete("{siteId}/{categoryId}")]
public IActionResult Delete([FromRoute] Guid siteId, [FromRoute] Guid categoryId) {
var result = _categoryItemService.Delete(siteId, categoryId);
return result.ToActionResult();
}
}