using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Authorization;
using DomainResults.Mvc;
using WeatherForecast.Services;
using WeatherForecast.Models.Requests;
namespace WeatherForecast.Controllers {
  /// 
  /// 
  /// 
  [ApiController]
  [AllowAnonymous]
  [Route("api/[controller]")]
  public class ShopCartItemController : ControllerBase {
    private readonly IShopCartItemService _shopCartItemService;
    /// 
    /// 
    /// 
    /// 
    public ShopCartItemController(
      IShopCartItemService shopCartItemService
    ) {
      _shopCartItemService = shopCartItemService;
    }
    /// 
    /// 
    /// 
    /// 
    /// 
    /// 
    /// 
    /// 
    [HttpPost("{siteId}/{userId}/{sku}")]
    public IActionResult Post([FromRoute] Guid siteId, [FromRoute] Guid userId, [FromRoute] string sku, [FromBody] ShopCartItemRequestModel 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, [FromQuery] string? locale) {
      var result = _shopCartItemService.Get(siteId, userId, sku, locale);
      return result.ToActionResult();
    }
    /// 
    /// 
    /// 
    /// 
    /// 
    /// 
    /// 
    /// 
    [HttpPut("{siteId}/{userId}/{sku}")]
    public IActionResult Update([FromRoute] Guid siteId, [FromRoute] Guid userId, [FromRoute] string sku, [FromBody] ShopCartItemRequestModel 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();
    }
  }
}