2024-02-19 13:56:49 +00:00
|
|
|
|
using DiscordRewards;
|
|
|
|
|
using Microsoft.AspNetCore.Mvc;
|
|
|
|
|
|
|
|
|
|
namespace BiblioTech.Rewards
|
|
|
|
|
{
|
|
|
|
|
public interface IDiscordRoleDriver
|
|
|
|
|
{
|
|
|
|
|
Task GiveRewards(GiveRewardsCommand rewards);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Route("api/[controller]")]
|
|
|
|
|
[ApiController]
|
|
|
|
|
public class RewardController : ControllerBase
|
|
|
|
|
{
|
|
|
|
|
[HttpGet]
|
|
|
|
|
public string Ping()
|
|
|
|
|
{
|
|
|
|
|
return "Pong";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[HttpPost]
|
|
|
|
|
public async Task<string> Give(GiveRewardsCommand cmd)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
2024-04-13 06:57:46 +00:00
|
|
|
|
if (cmd.Averages != null && cmd.Averages.Any())
|
|
|
|
|
{
|
|
|
|
|
Program.Averages = cmd.Averages;
|
|
|
|
|
}
|
2024-02-19 13:56:49 +00:00
|
|
|
|
await Program.RoleDriver.GiveRewards(cmd);
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
Program.Log.Error("Exception: " + ex);
|
|
|
|
|
}
|
|
|
|
|
return "OK";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|