mirror of
https://github.com/zoriya/Kyoo.git
synced 2025-07-08 18:54:22 -04:00
Implementing dispose pattern where repositories where used
This commit is contained in:
parent
7b266a2dff
commit
19715f795c
@ -126,7 +126,7 @@ namespace Kyoo.Controllers
|
|||||||
obj.ExternalIDs = (await Task.WhenAll(obj.ExternalIDs.Select(async x =>
|
obj.ExternalIDs = (await Task.WhenAll(obj.ExternalIDs.Select(async x =>
|
||||||
{
|
{
|
||||||
using IServiceScope serviceScope = _serviceProvider.CreateScope();
|
using IServiceScope serviceScope = _serviceProvider.CreateScope();
|
||||||
IProviderRepository providers = serviceScope.ServiceProvider.GetService<IProviderRepository>();
|
await using IProviderRepository providers = serviceScope.ServiceProvider.GetService<IProviderRepository>();
|
||||||
|
|
||||||
x.ProviderID = await providers.CreateIfNotExists(x.Provider);
|
x.ProviderID = await providers.CreateIfNotExists(x.Provider);
|
||||||
return x;
|
return x;
|
||||||
|
@ -101,7 +101,7 @@ namespace Kyoo.Controllers
|
|||||||
obj.ProviderLinks = (await Task.WhenAll(obj.ProviderLinks.Select(async x =>
|
obj.ProviderLinks = (await Task.WhenAll(obj.ProviderLinks.Select(async x =>
|
||||||
{
|
{
|
||||||
using IServiceScope serviceScope = _serviceProvider.CreateScope();
|
using IServiceScope serviceScope = _serviceProvider.CreateScope();
|
||||||
IProviderRepository providers = serviceScope.ServiceProvider.GetService<IProviderRepository>();
|
await using IProviderRepository providers = serviceScope.ServiceProvider.GetService<IProviderRepository>();
|
||||||
|
|
||||||
x.ProviderID = await providers.CreateIfNotExists(x.Provider);
|
x.ProviderID = await providers.CreateIfNotExists(x.Provider);
|
||||||
return x;
|
return x;
|
||||||
|
@ -100,7 +100,7 @@ namespace Kyoo.Controllers
|
|||||||
obj.ExternalIDs = (await Task.WhenAll(obj.ExternalIDs.Select(async x =>
|
obj.ExternalIDs = (await Task.WhenAll(obj.ExternalIDs.Select(async x =>
|
||||||
{
|
{
|
||||||
using IServiceScope serviceScope = _serviceProvider.CreateScope();
|
using IServiceScope serviceScope = _serviceProvider.CreateScope();
|
||||||
IProviderRepository providers = serviceScope.ServiceProvider.GetService<IProviderRepository>();
|
await using IProviderRepository providers = serviceScope.ServiceProvider.GetService<IProviderRepository>();
|
||||||
|
|
||||||
x.ProviderID = await providers.CreateIfNotExists(x.Provider);
|
x.ProviderID = await providers.CreateIfNotExists(x.Provider);
|
||||||
return x;
|
return x;
|
||||||
|
@ -119,7 +119,7 @@ namespace Kyoo.Controllers
|
|||||||
obj.ExternalIDs = (await Task.WhenAll(obj.ExternalIDs.Select(async x =>
|
obj.ExternalIDs = (await Task.WhenAll(obj.ExternalIDs.Select(async x =>
|
||||||
{
|
{
|
||||||
using IServiceScope serviceScope = _serviceProvider.CreateScope();
|
using IServiceScope serviceScope = _serviceProvider.CreateScope();
|
||||||
IProviderRepository providers = serviceScope.ServiceProvider.GetService<IProviderRepository>();
|
await using IProviderRepository providers = serviceScope.ServiceProvider.GetService<IProviderRepository>();
|
||||||
|
|
||||||
x.ProviderID = await providers.CreateIfNotExists(x.Provider);
|
x.ProviderID = await providers.CreateIfNotExists(x.Provider);
|
||||||
return x;
|
return x;
|
||||||
|
@ -122,7 +122,7 @@ namespace Kyoo.Controllers
|
|||||||
obj.GenreLinks = (await Task.WhenAll(obj.GenreLinks.Select(async x =>
|
obj.GenreLinks = (await Task.WhenAll(obj.GenreLinks.Select(async x =>
|
||||||
{
|
{
|
||||||
using IServiceScope serviceScope = _serviceProvider.CreateScope();
|
using IServiceScope serviceScope = _serviceProvider.CreateScope();
|
||||||
IGenreRepository genres = serviceScope.ServiceProvider.GetService<IGenreRepository>();
|
await using IGenreRepository genres = serviceScope.ServiceProvider.GetService<IGenreRepository>();
|
||||||
|
|
||||||
x.GenreID = await genres.CreateIfNotExists(x.Genre);
|
x.GenreID = await genres.CreateIfNotExists(x.Genre);
|
||||||
return x;
|
return x;
|
||||||
@ -134,7 +134,7 @@ namespace Kyoo.Controllers
|
|||||||
obj.People = (await Task.WhenAll(obj.People.Select(async x =>
|
obj.People = (await Task.WhenAll(obj.People.Select(async x =>
|
||||||
{
|
{
|
||||||
using IServiceScope serviceScope = _serviceProvider.CreateScope();
|
using IServiceScope serviceScope = _serviceProvider.CreateScope();
|
||||||
IPeopleRepository people = serviceScope.ServiceProvider.GetService<IPeopleRepository>();
|
await using IPeopleRepository people = serviceScope.ServiceProvider.GetService<IPeopleRepository>();
|
||||||
|
|
||||||
x.PeopleID = await people.CreateIfNotExists(x.People);
|
x.PeopleID = await people.CreateIfNotExists(x.People);
|
||||||
return x;
|
return x;
|
||||||
@ -146,7 +146,7 @@ namespace Kyoo.Controllers
|
|||||||
obj.ExternalIDs = (await Task.WhenAll(obj.ExternalIDs.Select(async x =>
|
obj.ExternalIDs = (await Task.WhenAll(obj.ExternalIDs.Select(async x =>
|
||||||
{
|
{
|
||||||
using IServiceScope serviceScope = _serviceProvider.CreateScope();
|
using IServiceScope serviceScope = _serviceProvider.CreateScope();
|
||||||
IProviderRepository providers = serviceScope.ServiceProvider.GetService<IProviderRepository>();
|
await using IProviderRepository providers = serviceScope.ServiceProvider.GetService<IProviderRepository>();
|
||||||
|
|
||||||
x.ProviderID = await providers.CreateIfNotExists(x.Provider);
|
x.ProviderID = await providers.CreateIfNotExists(x.Provider);
|
||||||
return x;
|
return x;
|
||||||
|
@ -51,7 +51,7 @@ namespace Kyoo.Controllers
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
using IServiceScope serviceScope = _serviceProvider.CreateScope();
|
using IServiceScope serviceScope = _serviceProvider.CreateScope();
|
||||||
ILibraryManager libraryManager = serviceScope.ServiceProvider.GetService<ILibraryManager>();
|
await using ILibraryManager libraryManager = serviceScope.ServiceProvider.GetService<ILibraryManager>();
|
||||||
ICollection<Episode> episodes = await libraryManager.GetEpisodes();
|
ICollection<Episode> episodes = await libraryManager.GetEpisodes();
|
||||||
ICollection<Library> libraries = argument == null
|
ICollection<Library> libraries = argument == null
|
||||||
? await libraryManager.GetLibraries()
|
? await libraryManager.GetLibraries()
|
||||||
@ -129,7 +129,7 @@ namespace Kyoo.Controllers
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
using IServiceScope serviceScope = _serviceProvider.CreateScope();
|
using IServiceScope serviceScope = _serviceProvider.CreateScope();
|
||||||
ILibraryManager libraryManager = serviceScope.ServiceProvider.GetService<ILibraryManager>();
|
await using ILibraryManager libraryManager = serviceScope.ServiceProvider.GetService<ILibraryManager>();
|
||||||
|
|
||||||
string patern = _config.GetValue<string>("regex");
|
string patern = _config.GetValue<string>("regex");
|
||||||
Regex regex = new Regex(patern, RegexOptions.IgnoreCase);
|
Regex regex = new Regex(patern, RegexOptions.IgnoreCase);
|
||||||
|
@ -12,7 +12,7 @@
|
|||||||
},
|
},
|
||||||
"AllowedHosts": "*",
|
"AllowedHosts": "*",
|
||||||
"ConnectionStrings": {
|
"ConnectionStrings": {
|
||||||
"Database": "Server=127.0.0.1; Port=5432; Database=kyooDB; User Id=kyoo; Password=kyooPassword;"
|
"Database": "Server=127.0.0.1; Port=5432; Database=kyooDB; User Id=kyoo; Password=kyooPassword; Pooling=true;"
|
||||||
},
|
},
|
||||||
|
|
||||||
"scheduledTasks": {
|
"scheduledTasks": {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user