fix: deserialize strings

This commit is contained in:
CyberL1 2024-04-17 08:17:23 +02:00
parent c5594b3460
commit bbf669f95b
4 changed files with 8 additions and 11 deletions

View File

@ -2,6 +2,7 @@
using Minecraft_Realms_Emulator.Attributes;
using Minecraft_Realms_Emulator.Data;
using Minecraft_Realms_Emulator.Responses;
using Newtonsoft.Json;
namespace Minecraft_Realms_Emulator.Controllers
{
@ -36,7 +37,7 @@ namespace Minecraft_Realms_Emulator.Controllers
var news = new NewsResponse
{
NewsLink = newsLink.Value
NewsLink = JsonConvert.DeserializeObject(newsLink.Value),
};
return news;

View File

@ -5,6 +5,7 @@ using Minecraft_Realms_Emulator.Data;
using Minecraft_Realms_Emulator.Entities;
using Minecraft_Realms_Emulator.Requests;
using Minecraft_Realms_Emulator.Responses;
using Newtonsoft.Json;
namespace Minecraft_Realms_Emulator.Controllers
{
@ -165,7 +166,7 @@ namespace Minecraft_Realms_Emulator.Controllers
var subscription = new Subscription
{
StartDate = DateTime.UtcNow,
SubscriptionType = SubscriptionType.NORMAL.ToString()
SubscriptionType = "NORMAL"
};
world.Name = body.Name;
@ -173,10 +174,12 @@ namespace Minecraft_Realms_Emulator.Controllers
world.State = "OPEN";
world.Subscription = subscription;
var defaultServerAddress = _context.Configuration.FirstOrDefault(x => x.Key == "defaultServerAddress");
var connection = new Connection
{
World = world,
Address = _context.Configuration.FirstOrDefault(x => x.Key == "defaultServerAddress").Value
Address = JsonConvert.DeserializeObject(defaultServerAddress.Value)
};
_context.Worlds.Update(world);

View File

@ -1,8 +0,0 @@
namespace Minecraft_Realms_Emulator.Entities
{
public enum SubscriptionType
{
NORMAL,
RECURRING
}
}

View File

@ -15,6 +15,7 @@
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="8.0.2" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.5.0" />
</ItemGroup>