using Fuel.Payment.Service.Pay;
using Microsoft.AspNetCore.Authorization;

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

namespace Fuel.PaymentServer.Controllers
{
    [ApiController]
    [Route("api/[controller]/[action]")]
    public class WeatherForecastController : ControllerBase
    {
        private static readonly string[] Summaries = new[]
        {
            "Freezing", "Bracing", "Chilly", "Cool", "Mild", "Warm", "Balmy", "Hot", "Sweltering", "Scorching"
        };

        private readonly ILogger<WeatherForecastController> _logger;
        private readonly IPayService _payService;

        public WeatherForecastController(ILogger<WeatherForecastController> logger, IPayService payService)
        {
            _logger = logger;
            _payService = payService;
        }


        /// <summary>
        /// GetWeatherForecast
        /// </summary>
        /// <returns></returns>
        [HttpGet(Name = "GetWeatherForecast")]
        public IEnumerable<WeatherForecast> Get()
        {
            return Enumerable.Range(1, 5).Select(index => new WeatherForecast
            {
                Date = DateOnly.FromDateTime(DateTime.Now.AddDays(index)),
                TemperatureC = Random.Shared.Next(-20, 55),
                Summary = Summaries[Random.Shared.Next(Summaries.Length)]
            })
            .ToArray();
        }
        /// <summary>
        /// Ìá½»Ö§¸¶
        /// </summary>
        /// <returns></returns>
        [HttpPost(Name = "Payment")]
        public async Task<IActionResult> Payment(string AuthCode)
        {
            await _payService.PerformElectronicProcess(AuthCode);
            return Ok(0);
        }

        /// <summary>
        /// get
        /// </summary>
        /// <returns></returns>
        [HttpGet(Name = "Apis")]
        [Authorize]
        public int GetApi()
        {
            return 0;
        }
    }
}
