60 lines
1.6 KiB
C#
60 lines
1.6 KiB
C#
using Microsoft.AspNetCore.Mvc;
|
|
using Microsoft.AspNetCore.Authorization;
|
|
|
|
using DomainResults.Mvc;
|
|
|
|
using WeatherForecast.Services;
|
|
|
|
namespace WeatherForecast.Controllers;
|
|
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
[ApiController]
|
|
[Route("api/[controller]")]
|
|
public class CategoryItemsController : ControllerBase {
|
|
|
|
private readonly IAuthorizationService _authorizationService;
|
|
private readonly ICategoryItemsService _categoryItemsService;
|
|
|
|
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
/// <param name="authorizationService"></param>
|
|
/// <param name="categoryItemsService"></param>
|
|
public CategoryItemsController(
|
|
IAuthorizationService authorizationService,
|
|
ICategoryItemsService categoryItemsService
|
|
) {
|
|
_authorizationService = authorizationService;
|
|
_categoryItemsService = categoryItemsService;
|
|
}
|
|
|
|
#region Authless methods
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
/// <param name="siteId"></param>
|
|
/// <param name="locale"></param>
|
|
/// <returns></returns>
|
|
[HttpGet("{siteId}")]
|
|
public IActionResult Get([FromRoute] Guid siteId, [FromQuery] string? locale) {
|
|
var result = _categoryItemsService.Get(siteId, locale);
|
|
return result.ToActionResult();
|
|
}
|
|
#endregion
|
|
|
|
//[HttpDelete("{siteId}")]
|
|
//public async Task<IActionResult> Delete([FromRoute] Guid siteId) {
|
|
// if ((await _authorizationService.AuthorizeAsync(User, null, new CategoryAuthorizationRequirement(true, CrudActions.Delete))).Succeeded) {
|
|
// var result = _categoryItemsService.Delete(siteId);
|
|
// return result.ToActionResult();
|
|
// }
|
|
// else {
|
|
// return Unauthorized();
|
|
// }
|
|
//}
|
|
}
|
|
|