mirror of https://github.com/ErsatzTV/ErsatzTV.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
25 lines
841 B
25 lines
841 B
using System.Data; |
|
using System.Threading; |
|
using System.Threading.Tasks; |
|
using Dapper; |
|
using MediatR; |
|
|
|
namespace ErsatzTV.Application.Libraries.Queries |
|
{ |
|
public class CountMediaItemsByLibraryHandler : IRequestHandler<CountMediaItemsByLibrary, int> |
|
{ |
|
private readonly IDbConnection _dbConnection; |
|
|
|
public CountMediaItemsByLibraryHandler(IDbConnection dbConnection) |
|
{ |
|
_dbConnection = dbConnection; |
|
} |
|
|
|
public Task<int> Handle(CountMediaItemsByLibrary request, CancellationToken cancellationToken) => |
|
_dbConnection.QuerySingleAsync<int>( |
|
@"SELECT COUNT(*) FROM MediaItem |
|
INNER JOIN LibraryPath LP on MediaItem.LibraryPathId = LP.Id |
|
WHERE LP.LibraryId = @LibraryId", |
|
new { request.LibraryId }); |
|
} |
|
}
|
|
|