using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Authorization;

using DomainResults.Mvc;

using WeatherForecast.Services;

namespace WeatherForecast.Controllers;


/// <summary>
/// 
/// </summary>
[Authorize]
[AllowAnonymous]
[Route("api/[controller]")]
public class ShopCartItemsController : ControllerBase {

  private readonly IShopCartItemsService _shopCartItemsService;

  /// <summary>
  /// 
  /// </summary>
  /// <param name="shopCartItemsService"></param>
  public ShopCartItemsController(
    IShopCartItemsService shopCartItemsService
  ) {
    _shopCartItemsService = shopCartItemsService;
  }

  /// <summary>
  /// 
  /// </summary>
  /// <returns></returns>
  [HttpGet("{siteId}/{userId}")]
  public IActionResult Get([FromRoute] Guid siteId, [FromRoute] Guid userId, [FromQuery] string? locale) {
    var result = _shopCartItemsService.Get(siteId, userId, locale);
    return result.ToActionResult();
  }

  /// <summary>
  /// 
  /// </summary>
  /// <param name="siteId"></param>
  /// <param name="userId"></param>
  /// <returns></returns>
  [HttpDelete("{siteId}/{userId}")]
  public IActionResult Delete([FromRoute] Guid siteId, [FromRoute] Guid userId) {
    var result = _shopCartItemsService.Delete(siteId, userId);
    return result.ToActionResult();
  }

}
