using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Authorization; using DomainResults.Mvc; using WeatherForecast.Services; using DataProviders.Collections; namespace WeatherForecast.Controllers; /// /// /// [ApiController] [Route("api/[controller]")] public class ShopItemsController : ControllerBase { private readonly IAuthorizationService _authorizationService; private readonly IShopCatalogDataProvider _shopCatalogDataProvider; private readonly IShopItemsService _shopItemsService; /// /// /// /// /// /// public ShopItemsController( IAuthorizationService authorizationService, IShopCatalogDataProvider shopCatalogDataProvider, IShopItemsService shopCatalogService ) { _authorizationService = authorizationService; _shopCatalogDataProvider = shopCatalogDataProvider; _shopItemsService = shopCatalogService; } #region Authless methods /// /// /// /// /// /// /// /// /// /// [HttpGet("{siteId}")] public IActionResult Get([FromRoute] Guid siteId, [FromQuery] Guid? category, [FromQuery] int? currentPage, [FromQuery] int? itemsPerPage, [FromQuery] string? locale, [FromQuery] string? searchText) { var result = _shopItemsService.Get(siteId, category, currentPage ?? 1, itemsPerPage ?? 8, locale, searchText); return result.ToActionResult(); } #endregion //[HttpDelete("{siteId}")] //public async Task Delete([FromRoute] Guid siteId) { // if ((await _authorizationService.AuthorizeAsync(User, null, new CrudActionRequirement(_webapiController, CrudActions.Create))).Succeeded) { // var result = _shopItemsService.Delete(siteId); // return result.ToActionResult(); // } // return Unauthorized(); //} }