mirror of
				https://github.com/zoriya/Kyoo.git
				synced 2025-11-04 03:27:14 -05:00 
			
		
		
		
	Solving a bug with collections
This commit is contained in:
		
							parent
							
								
									7e20e7d318
								
							
						
					
					
						commit
						b79ed8a198
					
				@ -60,7 +60,7 @@ namespace Kyoo.Models
 | 
			
		||||
		{
 | 
			
		||||
			Slug = slug;
 | 
			
		||||
			Title = title;
 | 
			
		||||
			Aliases = aliases.ToArray();
 | 
			
		||||
			Aliases = aliases?.ToArray();
 | 
			
		||||
			Path = path;
 | 
			
		||||
			Overview = overview;
 | 
			
		||||
			TrailerUrl = trailerUrl;
 | 
			
		||||
@ -76,7 +76,7 @@ namespace Kyoo.Models
 | 
			
		||||
		{
 | 
			
		||||
			Slug = slug;
 | 
			
		||||
			Title = title;
 | 
			
		||||
			Aliases = aliases.ToArray();
 | 
			
		||||
			Aliases = aliases?.ToArray();
 | 
			
		||||
			Path = path;
 | 
			
		||||
			Overview = overview;
 | 
			
		||||
			TrailerUrl = trailerUrl;
 | 
			
		||||
 | 
			
		||||
@ -93,6 +93,8 @@ namespace Kyoo.Controllers
 | 
			
		||||
				if (_libraryManager.RegisterEpisode(episode) == 0)
 | 
			
		||||
					return;
 | 
			
		||||
			}
 | 
			
		||||
			if (collection != null)
 | 
			
		||||
				_libraryManager.RegisterCollection(collection);
 | 
			
		||||
			_libraryManager.RegisterShowLinks(library, collection, show);
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -62,9 +62,7 @@ namespace Kyoo.Controllers
 | 
			
		||||
 | 
			
		||||
		public IEnumerable<Show> GetShows()
 | 
			
		||||
		{
 | 
			
		||||
			return (from show in _database.Shows from l in _database.CollectionLinks.DefaultIfEmpty()
 | 
			
		||||
				where l.CollectionID == null select show).AsEnumerable().Union(
 | 
			
		||||
				from collection in _database.Collections select collection.AsShow()).OrderBy(x => x.Title);
 | 
			
		||||
			return _database.LibraryLinks.AsEnumerable().Select(x => x.Show ?? x.Collection.AsShow());
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		public IEnumerable<Show> GetShows(string searchQuery)
 | 
			
		||||
@ -220,7 +218,10 @@ namespace Kyoo.Controllers
 | 
			
		||||
 | 
			
		||||
		public Collection GetCollection(string slug)
 | 
			
		||||
		{
 | 
			
		||||
			return (from collection in _database.Collections where collection.Slug == slug select collection).FirstOrDefault();
 | 
			
		||||
			Collection collection = _database.Collections.Where(collection => collection.Slug == slug).FirstOrDefault();
 | 
			
		||||
			if (collection != null)
 | 
			
		||||
				collection.Shows = GetShowsInCollection(collection.ID);
 | 
			
		||||
			return collection;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		public IEnumerable<Show> GetShowsInCollection(long collectionID)
 | 
			
		||||
@ -232,12 +233,7 @@ namespace Kyoo.Controllers
 | 
			
		||||
		{
 | 
			
		||||
			return (from link in _database.LibraryLinks where link.LibraryID == libraryID select link)
 | 
			
		||||
				.AsEnumerable()
 | 
			
		||||
				.Select(link =>
 | 
			
		||||
				{
 | 
			
		||||
					_database.Entry(link).Reference(l => l.Show).Load();
 | 
			
		||||
					_database.Entry(link).Reference(l => l.Collection).Load();
 | 
			
		||||
					return link.Show ?? link.Collection.AsShow();
 | 
			
		||||
				})
 | 
			
		||||
				.Select(link => link.Show ?? link.Collection.AsShow())
 | 
			
		||||
				.OrderBy(x => x.Title);
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
@ -395,6 +391,7 @@ namespace Kyoo.Controllers
 | 
			
		||||
				_database.LibraryLinks.AddIfNotExist(new LibraryLink {LibraryID = library.ID, CollectionID = collection.ID}, x => x.LibraryID == library.ID && x.CollectionID == collection.ID && x.ShowID == null);
 | 
			
		||||
				_database.CollectionLinks.AddIfNotExist(new CollectionLink { CollectionID = collection.ID, ShowID = show.ID}, x => x.CollectionID == collection.ID && x.ShowID == show.ID);
 | 
			
		||||
			}
 | 
			
		||||
			else
 | 
			
		||||
				_database.LibraryLinks.AddIfNotExist(new LibraryLink {LibraryID = library.ID, ShowID = show.ID}, x => x.LibraryID == library.ID && x.CollectionID == null && x.ShowID == show.ID);
 | 
			
		||||
			_database.SaveChanges();
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
@ -28,7 +28,7 @@ namespace Kyoo.Controllers
 | 
			
		||||
					if (library.Providers.Contains(provider.Name))
 | 
			
		||||
						ret = ret.Merge(await providerCall(provider));
 | 
			
		||||
				} catch (Exception ex) {
 | 
			
		||||
					Console.Error.WriteLine($"The provider {provider.Name} coudln't work for {what}. Exception: {ex.Message}");
 | 
			
		||||
					Console.Error.WriteLine($"\tThe provider {provider.Name} coudln't work for {what}. Exception: {ex.Message}");
 | 
			
		||||
				}
 | 
			
		||||
			}
 | 
			
		||||
			return ret;
 | 
			
		||||
@ -45,7 +45,7 @@ namespace Kyoo.Controllers
 | 
			
		||||
					if (library.Providers.Contains(provider.Name))
 | 
			
		||||
						ret.AddRange(await providerCall(provider) ?? new List<T>());
 | 
			
		||||
				} catch (Exception ex) {
 | 
			
		||||
					Console.Error.WriteLine($"The provider {provider.Name} coudln't work for {what}. Exception: {ex.Message}");
 | 
			
		||||
					Console.Error.WriteLine($"\tThe provider {provider.Name} coudln't work for {what}. Exception: {ex.Message}");
 | 
			
		||||
				}
 | 
			
		||||
			}
 | 
			
		||||
			return ret;
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user