mirror of
https://github.com/zoriya/Kyoo.git
synced 2025-05-31 12:14:46 -04:00
Adding the /show/studio
This commit is contained in:
parent
fb2d5b24bd
commit
1f53affafa
@ -148,6 +148,9 @@ namespace Kyoo.Controllers
|
|||||||
Expression<Func<Genre, object>> sort,
|
Expression<Func<Genre, object>> sort,
|
||||||
Pagination limit = default
|
Pagination limit = default
|
||||||
) => GetGenresFromShow(showSlug, where, new Sort<Genre>(sort), limit);
|
) => GetGenresFromShow(showSlug, where, new Sort<Genre>(sort), limit);
|
||||||
|
|
||||||
|
Task<Studio> GetStudioFromShow(int showID);
|
||||||
|
Task<Studio> GetStudioFromShow(string showSlug);
|
||||||
|
|
||||||
|
|
||||||
// Helpers
|
// Helpers
|
||||||
|
@ -218,7 +218,12 @@ namespace Kyoo.Controllers
|
|||||||
Pagination limit = default
|
Pagination limit = default
|
||||||
) => GetFromShow(showSlug, where, new Sort<Genre>(sort), limit);
|
) => GetFromShow(showSlug, where, new Sort<Genre>(sort), limit);
|
||||||
}
|
}
|
||||||
public interface IStudioRepository : IRepository<Studio> {}
|
|
||||||
|
public interface IStudioRepository : IRepository<Studio>
|
||||||
|
{
|
||||||
|
Task<Studio> GetFromShow(int showID);
|
||||||
|
Task<Studio> GetFromShow(string showSlug);
|
||||||
|
}
|
||||||
|
|
||||||
public interface IPeopleRepository : IRepository<People>
|
public interface IPeopleRepository : IRepository<People>
|
||||||
{
|
{
|
||||||
|
@ -286,7 +286,17 @@ namespace Kyoo.Controllers
|
|||||||
{
|
{
|
||||||
return GenreRepository.GetFromShow(showSlug, where, sort, limit);
|
return GenreRepository.GetFromShow(showSlug, where, sort, limit);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Task<Studio> GetStudioFromShow(int showID)
|
||||||
|
{
|
||||||
|
return StudioRepository.GetFromShow(showID);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Task<Studio> GetStudioFromShow(string showSlug)
|
||||||
|
{
|
||||||
|
return StudioRepository.GetFromShow(showSlug);
|
||||||
|
}
|
||||||
|
|
||||||
public Task AddShowLink(int showID, int? libraryID, int? collectionID)
|
public Task AddShowLink(int showID, int? libraryID, int? collectionID)
|
||||||
{
|
{
|
||||||
return ShowRepository.AddShowLink(showID, libraryID, collectionID);
|
return ShowRepository.AddShowLink(showID, libraryID, collectionID);
|
||||||
|
@ -66,5 +66,27 @@ namespace Kyoo.Controllers
|
|||||||
show.StudioID = null;
|
show.StudioID = null;
|
||||||
await _database.SaveChangesAsync();
|
await _database.SaveChangesAsync();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public async Task<Studio> GetFromShow(int showID)
|
||||||
|
{
|
||||||
|
Studio studio = await _database.Shows
|
||||||
|
.Where(x => x.ID == showID)
|
||||||
|
.Select(x => x.Studio)
|
||||||
|
.FirstOrDefaultAsync();
|
||||||
|
if (studio == null && !_database.Shows.Any(x => x.ID == showID))
|
||||||
|
throw new ItemNotFound();
|
||||||
|
return studio;
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<Studio> GetFromShow(string showSlug)
|
||||||
|
{
|
||||||
|
Studio studio = await _database.Shows
|
||||||
|
.Where(x => x.Slug == showSlug)
|
||||||
|
.Select(x => x.Studio)
|
||||||
|
.FirstOrDefaultAsync();
|
||||||
|
if (studio == null && !_database.Shows.Any(x => x.Slug == showSlug))
|
||||||
|
throw new ItemNotFound();
|
||||||
|
return studio;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -48,7 +48,7 @@ namespace Kyoo
|
|||||||
options.UseLazyLoadingProxies()
|
options.UseLazyLoadingProxies()
|
||||||
.UseNpgsql(_configuration.GetConnectionString("Database"));
|
.UseNpgsql(_configuration.GetConnectionString("Database"));
|
||||||
// .EnableSensitiveDataLogging()
|
// .EnableSensitiveDataLogging()
|
||||||
//.UseLoggerFactory(LoggerFactory.Create(builder => builder.AddConsole()));
|
// .UseLoggerFactory(LoggerFactory.Create(builder => builder.AddConsole()));
|
||||||
}, ServiceLifetime.Transient);
|
}, ServiceLifetime.Transient);
|
||||||
|
|
||||||
services.AddDbContext<IdentityDatabase>(options =>
|
services.AddDbContext<IdentityDatabase>(options =>
|
||||||
|
@ -286,5 +286,33 @@ namespace Kyoo.Api
|
|||||||
return BadRequest(new {Error = ex.Message});
|
return BadRequest(new {Error = ex.Message});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[HttpGet("{showID:int}/studio")]
|
||||||
|
[Authorize(Policy = "Read")]
|
||||||
|
public async Task<ActionResult<Studio>> GetStudio(int showID)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
return await _libraryManager.GetStudioFromShow(showID);
|
||||||
|
}
|
||||||
|
catch (ItemNotFound)
|
||||||
|
{
|
||||||
|
return NotFound();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpGet("{slug}/studio")]
|
||||||
|
[Authorize(Policy = "Read")]
|
||||||
|
public async Task<ActionResult<Studio>> GetStudio(string slug)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
return await _libraryManager.GetStudioFromShow(slug);
|
||||||
|
}
|
||||||
|
catch (ItemNotFound)
|
||||||
|
{
|
||||||
|
return NotFound();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user