TourIAm/TIAMWebApp/Server/Controllers/ExchangeRateAPIController.cs

56 lines
1.8 KiB
C#

using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using QRCoder;
using System.Drawing;
using System.Drawing.Imaging;
using AyCode.Core.Enums;
using AyCode.Core.Extensions;
using TIAM.Database.DataLayers.Admins;
using TIAM.Entities.ServiceProviders;
using TIAM.Entities.Users;
using TIAMWebApp.Shared.Application.Models;
using Product = TIAM.Entities.Products.Product;
using TIAM.Entities.Addresses;
using TIAM.Entities.Profiles;
using AyCode.Core.Loggers;
using AyCode.Entities;
using AyCode.Services.SignalRs;
using AyCode.Utils.Extensions;
using TIAM.Entities.Drivers;
using TIAM.Services;
using TIAMWebApp.Server.Services;
using GoogleApi.Entities.Search.Video.Common;
namespace TIAMWebApp.Server.Controllers
{
[ApiController]
[Route("api/v1/[controller]")]
public class ExchangeRateAPIController(ExchangeRateService _service,IEnumerable<IAcLogWriterBase> logWriters) : ControllerBase
{
private readonly TIAM.Core.Loggers.Logger<ExchangeRateAPIController> _logger = new(logWriters.ToArray());
[AllowAnonymous]
[HttpGet]
[Route(APIUrls.GetExchangeRateRouteName)]
//[SignalR(SignalRTags.GetProfileById)]
public async Task<IActionResult> GetExchangeRate()
{
_logger.Info($@"GetExchangeRate called");
var rate = await _service.GetExchangeRateAsync();
return Ok(rate);
}
[AllowAnonymous]
[HttpPost]
[Route(APIUrls.UpdateExchangeRateRouteName)]
//[SignalR(SignalRTags.GetProfileById)]
public async Task<IActionResult> Set([FromBody] ExchangeRate rate)
{
_logger.Info($@"GetServiceProviderById called with rate: {rate.EURtoHUF}");
await _service.SetExchangeRateAsync(rate);
return Ok();
}
}
}