using DomainResults.Mvc;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using WeatherForecast.Models.Requests;
using WeatherForecast.Services;
namespace WeatherForecast.Controllers {
///
///
///
[ApiController]
[AllowAnonymous]
[Route("api/[controller]")]
public class ShopCartItemController : ControllerBase {
private readonly ILogger _logger;
private readonly IShopCartItemService _shopCartItemService;
///
///
///
///
public ShopCartItemController(
ILogger logger,
IShopCartItemService shopCartItemService
) {
_logger = logger;
_shopCartItemService = shopCartItemService;
}
///
///
///
///
///
///
///
///
[HttpPost("{siteId}/{userId}/{sku}")]
public IActionResult Post([FromRoute] Guid siteId, [FromRoute] Guid userId, [FromRoute] string sku, [FromBody] PostShopCartItemRequestModel requestData) {
var result = _shopCartItemService.Post(siteId, userId, sku, requestData);
return result.ToActionResult();
}
///
///
///
///
[HttpGet("{siteId}/{userId}/{sku}")]
public IActionResult Get([FromRoute] Guid siteId, [FromRoute] Guid userId, [FromRoute] string sku) {
var result = _shopCartItemService.Get(siteId, userId, sku);
return result.ToActionResult();
}
///
///
///
///
///
///
///
///
[HttpPut("{siteId}/{userId}/{sku}")]
public IActionResult Update([FromRoute] Guid siteId, [FromRoute] Guid userId, [FromRoute] string sku, [FromBody] PutShopCartItemRequestModel requestData) {
var result = _shopCartItemService.Update(siteId, userId, sku, requestData);
return result.ToActionResult();
}
///
///
///
///
///
///
///
[HttpDelete("{siteId}/{userId}/{sku}")]
public IActionResult Delete([FromRoute] Guid siteId, [FromRoute] Guid userId, [FromRoute] string sku) {
var result = _shopCartItemService.Delete(siteId, userId, sku);
return result.ToActionResult();
}
}
}