using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; using Microsoft.EntityFrameworkCore; using RadicadeServer.DB; using RadicadeServer.Extensions; using RadicadeServer.RecNet.Enums.Store; using RadicadeServer.RecNet.Responses; using RadicadeServer.Utils; namespace RadicadeServer.API.Storefront.V4; [Route("api/storefronts/v4")] [Route("econ/api/storefronts/v4")] public class StorefrontsV4(RecDBContext db) : Controller { [HttpGet("balance/{type}"), Authorize] public async Task?> GetBalance(CurrencyType type) { var userId = User.GetUserId(); var data = await db.Currency.FirstOrDefaultAsync(x => x.AccountId == userId); long balance; if (type == CurrencyType.RecRoyale_Season1) { var progression = await db.Progression.FirstOrDefaultAsync(x => x.PlayerId == userId); balance = progression == null ? 0 : LevelUpGiftService.XpIntoCurrentLevel(progression); } else { if (data == null) return []; balance = type switch { CurrencyType.RecCenterTokens => data.RecTokens, CurrencyType.LaserTagTickets => data.LaserTagTickets, CurrencyType.LostSkullsGold => data.Gold, CurrencyType.DraculaSilver => data.DraculaSilver, _ => 0 }; } return new List { new() { CurrencyType = type, Balance = balance } }; } }