Adding id & slug based delete

This commit is contained in:
Zoe Roux 2020-06-20 18:14:23 +02:00
parent 48fc4fd249
commit 0952197cf6
11 changed files with 136 additions and 0 deletions

View File

@ -15,6 +15,8 @@ namespace Kyoo.Controllers
Task<int> Create([NotNull] T obj);
Task<int> 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<Season>
{
Task<Season> Get(string showSlug, int seasonNumber);
Task Delete(string showSlug, int seasonNumber);
Task<ICollection<Season>> GetSeasons(int showID);
Task<ICollection<Season>> GetSeasons(string showSlug);
@ -35,6 +38,7 @@ namespace Kyoo.Controllers
public interface IEpisodeRepository : IRepository<Episode>
{
Task<Episode> Get(string showSlug, int seasonNumber, int episodeNumber);
Task Delete(string showSlug, int seasonNumber, int episodeNumber);
Task<ICollection<Episode>> GetEpisodes(int showID, int seasonNumber);
Task<ICollection<Episode>> GetEpisodes(string showSlug, int seasonNumber);

View File

@ -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)

View File

@ -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)

View File

@ -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)
{

View File

@ -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)

View File

@ -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)
{

View File

@ -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)

View File

@ -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)
{

View File

@ -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)

View File

@ -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)

View File

@ -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)