mirror of
https://github.com/zoriya/Kyoo.git
synced 2025-07-09 03:04:20 -04:00
Handlink genre link deletion
This commit is contained in:
parent
40c3fcbb91
commit
25274548c4
@ -1,4 +1,7 @@
|
||||
using Newtonsoft.Json;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Kyoo.Models.Attributes;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace Kyoo.Models
|
||||
{
|
||||
@ -8,7 +11,13 @@ namespace Kyoo.Models
|
||||
public string Slug { get; set; }
|
||||
public string Name { get; set; }
|
||||
|
||||
// public IEnumerable<Show> Shows { get; set; }
|
||||
[NotMergable] [JsonIgnore] public IEnumerable<GenreLink> Links { get; set; }
|
||||
|
||||
[NotMergable] [JsonIgnore] public IEnumerable<Show> Shows
|
||||
{
|
||||
get => Links.Select(x => x.Show);
|
||||
set => Links = value?.Select(x => new GenreLink(x, this));
|
||||
}
|
||||
|
||||
public Genre() {}
|
||||
|
||||
|
@ -115,8 +115,11 @@ namespace Kyoo.Controllers
|
||||
{
|
||||
if (obj == null)
|
||||
throw new ArgumentNullException(nameof(obj));
|
||||
|
||||
_database.Genres.Remove(obj);
|
||||
|
||||
_database.Entry(obj).State = EntityState.Deleted;
|
||||
if (obj.Links != null)
|
||||
foreach (GenreLink link in obj.Links)
|
||||
_database.Entry(link).State = EntityState.Deleted;
|
||||
await _database.SaveChangesAsync();
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user