use full preferred language names in ui (#137)
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Dapper;
|
||||
using ErsatzTV.Core.Domain;
|
||||
using ErsatzTV.Core.Interfaces.Repositories;
|
||||
using LanguageExt;
|
||||
@@ -11,10 +13,14 @@ namespace ErsatzTV.Infrastructure.Data.Repositories
|
||||
{
|
||||
public class MediaItemRepository : IMediaItemRepository
|
||||
{
|
||||
private readonly IDbConnection _dbConnection;
|
||||
private readonly IDbContextFactory<TvContext> _dbContextFactory;
|
||||
|
||||
public MediaItemRepository(IDbContextFactory<TvContext> dbContextFactory) =>
|
||||
public MediaItemRepository(IDbContextFactory<TvContext> dbContextFactory, IDbConnection dbConnection)
|
||||
{
|
||||
_dbContextFactory = dbContextFactory;
|
||||
_dbConnection = dbConnection;
|
||||
}
|
||||
|
||||
public async Task<Option<MediaItem>> Get(int id)
|
||||
{
|
||||
@@ -38,5 +44,16 @@ namespace ErsatzTV.Infrastructure.Data.Repositories
|
||||
context.MediaItems.Update(mediaItem);
|
||||
return await context.SaveChangesAsync() > 0;
|
||||
}
|
||||
|
||||
public Task<List<string>> GetAllLanguageCodes() =>
|
||||
_dbConnection.QueryAsync<string>(
|
||||
@"SELECT LanguageCode FROM
|
||||
(SELECT Language AS LanguageCode
|
||||
FROM MediaStream WHERE Language IS NOT NULL
|
||||
UNION ALL SELECT PreferredLanguageCode AS LanguageCode
|
||||
FROM Channel WHERE PreferredLanguageCode IS NOT NULL)
|
||||
GROUP BY LanguageCode
|
||||
ORDER BY COUNT(LanguageCode) DESC")
|
||||
.Map(result => result.ToList());
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user