Refactored and cleaned some stuff
This commit is contained in:
@@ -1,4 +1,8 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using MoonCore.Abstractions;
|
||||
using MoonCore.Helpers;
|
||||
using Moonlight.Features.Servers.Entities;
|
||||
using Moonlight.Features.Servers.Exceptions;
|
||||
using Moonlight.Features.Servers.Models.Abstractions;
|
||||
|
||||
namespace Moonlight.Features.Servers.Extensions;
|
||||
@@ -71,4 +75,17 @@ public static class ServerExtensions
|
||||
|
||||
return installConfiguration;
|
||||
}
|
||||
|
||||
public static HttpApiClient<NodeException> CreateHttpClient(this Server server, IServiceProvider serviceProvider)
|
||||
{
|
||||
using var scope = serviceProvider.CreateScope();
|
||||
var serverRepo = scope.ServiceProvider.GetRequiredService<Repository<Server>>();
|
||||
|
||||
var serverWithNode = serverRepo
|
||||
.Get()
|
||||
.Include(x => x.Node)
|
||||
.First(x => x.Id == server.Id);
|
||||
|
||||
return serverWithNode.Node.CreateHttpClient();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user