From 0952197cf6759da6b461bf06cb69a79cfb6de5b3 Mon Sep 17 00:00:00 2001 From: Zoe Roux Date: Sat, 20 Jun 2020 18:14:23 +0200 Subject: [PATCH] Adding id & slug based delete --- Kyoo.Common/Controllers/IRepository.cs | 4 ++++ .../Repositories/CollectionRepository.cs | 12 ++++++++++++ .../Repositories/EpisodeRepository.cs | 18 ++++++++++++++++++ .../Repositories/GenreRepository.cs | 12 ++++++++++++ .../Repositories/LibraryRepository.cs | 12 ++++++++++++ .../Repositories/PeopleRepository.cs | 12 ++++++++++++ .../Repositories/ProviderRepository.cs | 12 ++++++++++++ .../Repositories/SeasonRepository.cs | 18 ++++++++++++++++++ .../Controllers/Repositories/ShowRepository.cs | 12 ++++++++++++ .../Repositories/StudioRepository.cs | 12 ++++++++++++ .../Repositories/TrackRepository.cs | 12 ++++++++++++ 11 files changed, 136 insertions(+) diff --git a/Kyoo.Common/Controllers/IRepository.cs b/Kyoo.Common/Controllers/IRepository.cs index e4c64b04..705ff12f 100644 --- a/Kyoo.Common/Controllers/IRepository.cs +++ b/Kyoo.Common/Controllers/IRepository.cs @@ -15,6 +15,8 @@ namespace Kyoo.Controllers Task Create([NotNull] T obj); Task CreateIfNotExists([NotNull] T obj); Task Edit([NotNull] T edited, bool resetOld); + Task Delete(int id); + Task Delete(string slug); Task Delete([NotNull] T obj); } @@ -27,6 +29,7 @@ namespace Kyoo.Controllers public interface ISeasonRepository : IRepository { Task Get(string showSlug, int seasonNumber); + Task Delete(string showSlug, int seasonNumber); Task> GetSeasons(int showID); Task> GetSeasons(string showSlug); @@ -35,6 +38,7 @@ namespace Kyoo.Controllers public interface IEpisodeRepository : IRepository { Task Get(string showSlug, int seasonNumber, int episodeNumber); + Task Delete(string showSlug, int seasonNumber, int episodeNumber); Task> GetEpisodes(int showID, int seasonNumber); Task> GetEpisodes(string showSlug, int seasonNumber); diff --git a/Kyoo/Controllers/Repositories/CollectionRepository.cs b/Kyoo/Controllers/Repositories/CollectionRepository.cs index 5e3fcd43..139df7d4 100644 --- a/Kyoo/Controllers/Repositories/CollectionRepository.cs +++ b/Kyoo/Controllers/Repositories/CollectionRepository.cs @@ -111,6 +111,18 @@ namespace Kyoo.Controllers await _database.SaveChangesAsync(); } + public async Task Delete(int id) + { + Collection obj = await Get(id); + await Delete(obj); + } + + public async Task Delete(string slug) + { + Collection obj = await Get(slug); + await Delete(obj); + } + public async Task Delete(Collection obj) { if (obj == null) diff --git a/Kyoo/Controllers/Repositories/EpisodeRepository.cs b/Kyoo/Controllers/Repositories/EpisodeRepository.cs index c26aae88..ca7e4027 100644 --- a/Kyoo/Controllers/Repositories/EpisodeRepository.cs +++ b/Kyoo/Controllers/Repositories/EpisodeRepository.cs @@ -156,6 +156,24 @@ namespace Kyoo.Controllers } } + public async Task Delete(int id) + { + Episode obj = await Get(id); + await Delete(obj); + } + + public async Task Delete(string slug) + { + Episode obj = await Get(slug); + await Delete(obj); + } + + public async Task Delete(string showSlug, int seasonNumber, int episodeNumber) + { + Episode obj = await Get(showSlug, seasonNumber, episodeNumber); + await Delete(obj); + } + public async Task Delete(Episode obj) { if (obj == null) diff --git a/Kyoo/Controllers/Repositories/GenreRepository.cs b/Kyoo/Controllers/Repositories/GenreRepository.cs index a9e444ea..0da62f6d 100644 --- a/Kyoo/Controllers/Repositories/GenreRepository.cs +++ b/Kyoo/Controllers/Repositories/GenreRepository.cs @@ -110,6 +110,18 @@ namespace Kyoo.Controllers Utility.Merge(old, edited); await _database.SaveChangesAsync(); } + + public async Task Delete(int id) + { + Genre obj = await Get(id); + await Delete(obj); + } + + public async Task Delete(string slug) + { + Genre obj = await Get(slug); + await Delete(obj); + } public async Task Delete(Genre obj) { diff --git a/Kyoo/Controllers/Repositories/LibraryRepository.cs b/Kyoo/Controllers/Repositories/LibraryRepository.cs index c6171bc0..5f29e98e 100644 --- a/Kyoo/Controllers/Repositories/LibraryRepository.cs +++ b/Kyoo/Controllers/Repositories/LibraryRepository.cs @@ -124,6 +124,18 @@ namespace Kyoo.Controllers link.ProviderID = await _providers.CreateIfNotExists(link.Provider); } + public async Task Delete(int id) + { + Library obj = await Get(id); + await Delete(obj); + } + + public async Task Delete(string slug) + { + Library obj = await Get(slug); + await Delete(obj); + } + public async Task Delete(Library obj) { if (obj == null) diff --git a/Kyoo/Controllers/Repositories/PeopleRepository.cs b/Kyoo/Controllers/Repositories/PeopleRepository.cs index 6c3eb0c6..60102aff 100644 --- a/Kyoo/Controllers/Repositories/PeopleRepository.cs +++ b/Kyoo/Controllers/Repositories/PeopleRepository.cs @@ -122,6 +122,18 @@ namespace Kyoo.Controllers foreach (MetadataID link in obj.ExternalIDs) link.ProviderID = await _providers.CreateIfNotExists(link.Provider); } + + public async Task Delete(int id) + { + People obj = await Get(id); + await Delete(obj); + } + + public async Task Delete(string slug) + { + People obj = await Get(slug); + await Delete(obj); + } public async Task Delete(People obj) { diff --git a/Kyoo/Controllers/Repositories/ProviderRepository.cs b/Kyoo/Controllers/Repositories/ProviderRepository.cs index 156f9440..0ed4614d 100644 --- a/Kyoo/Controllers/Repositories/ProviderRepository.cs +++ b/Kyoo/Controllers/Repositories/ProviderRepository.cs @@ -110,6 +110,18 @@ namespace Kyoo.Controllers await _database.SaveChangesAsync(); } + public async Task Delete(int id) + { + ProviderID obj = await Get(id); + await Delete(obj); + } + + public async Task Delete(string slug) + { + ProviderID obj = await Get(slug); + await Delete(obj); + } + public async Task Delete(ProviderID obj) { if (obj == null) diff --git a/Kyoo/Controllers/Repositories/SeasonRepository.cs b/Kyoo/Controllers/Repositories/SeasonRepository.cs index e27cf755..7ed56125 100644 --- a/Kyoo/Controllers/Repositories/SeasonRepository.cs +++ b/Kyoo/Controllers/Repositories/SeasonRepository.cs @@ -143,6 +143,24 @@ namespace Kyoo.Controllers link.ProviderID = await _providers.CreateIfNotExists(link.Provider); } } + + public async Task Delete(int id) + { + Season obj = await Get(id); + await Delete(obj); + } + + public async Task Delete(string slug) + { + Season obj = await Get(slug); + await Delete(obj); + } + + public async Task Delete(string showSlug, int seasonNumber) + { + Season obj = await Get(showSlug, seasonNumber); + await Delete(obj); + } public async Task Delete(Season obj) { diff --git a/Kyoo/Controllers/Repositories/ShowRepository.cs b/Kyoo/Controllers/Repositories/ShowRepository.cs index 6821e61f..f355c5cc 100644 --- a/Kyoo/Controllers/Repositories/ShowRepository.cs +++ b/Kyoo/Controllers/Repositories/ShowRepository.cs @@ -163,6 +163,18 @@ namespace Kyoo.Controllers link.ProviderID = await _providers.CreateIfNotExists(link.Provider); } + public async Task Delete(int id) + { + Show obj = await Get(id); + await Delete(obj); + } + + public async Task Delete(string slug) + { + Show obj = await Get(slug); + await Delete(obj); + } + public async Task Delete(Show obj) { if (obj == null) diff --git a/Kyoo/Controllers/Repositories/StudioRepository.cs b/Kyoo/Controllers/Repositories/StudioRepository.cs index c9b56777..e6bf7578 100644 --- a/Kyoo/Controllers/Repositories/StudioRepository.cs +++ b/Kyoo/Controllers/Repositories/StudioRepository.cs @@ -109,6 +109,18 @@ namespace Kyoo.Controllers await _database.SaveChangesAsync(); } + public async Task Delete(int id) + { + Studio obj = await Get(id); + await Delete(obj); + } + + public async Task Delete(string slug) + { + Studio obj = await Get(slug); + await Delete(obj); + } + public async Task Delete(Studio obj) { if (obj == null) diff --git a/Kyoo/Controllers/Repositories/TrackRepository.cs b/Kyoo/Controllers/Repositories/TrackRepository.cs index 25d034e2..89284f29 100644 --- a/Kyoo/Controllers/Repositories/TrackRepository.cs +++ b/Kyoo/Controllers/Repositories/TrackRepository.cs @@ -99,6 +99,18 @@ namespace Kyoo.Controllers await _database.SaveChangesAsync(); } + public async Task Delete(int id) + { + Track obj = await Get(id); + await Delete(obj); + } + + public async Task Delete(string slug) + { + Track obj = await Get(slug); + await Delete(obj); + } + public async Task Delete(Track obj) { if (obj == null)