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

using WeatherForecast.Models.Requests;
using WeatherForecast.Services;

namespace WeatherForecast.Controllers;

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

  private readonly IAuthenticationService _authenticationService;

  /// <summary>
  /// 
  /// </summary>
  /// <param name="authenticationService"></param>
  public AuthenticationController(
    IAuthenticationService authenticationService
  ) {
    _authenticationService = authenticationService;
  }

  /// <summary>
  /// 
  /// </summary>
  /// <param name="siteId"></param>
  /// <param name="requestData"></param>
  /// <returns></returns>
  [HttpPost("{siteId}")]
  public IActionResult Post([FromRoute] Guid siteId, [FromBody] AuthenticationRequestModel requestData) {
    var result = _authenticationService.Post(siteId, requestData);
    return result.ToActionResult();
  }
}

