Selector/Selector.Model/Extensions/ScrobbleRepositoryExtensions.cs

30 lines
1015 B
C#
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

using System;
namespace Selector.Model.Extensions
{
public static class ScrobbleRepositoryExtensions
{
public static int CountToday(this IScrobbleRepository repo, string userId = null, string username = null, string track = null, string album = null, string artist = null)
{
if (!string.IsNullOrWhiteSpace(userId))
{
return repo.Count(userId: userId, from: DateTime.Now.ToUniversalTime().Date,
artistName: artist,
albumName: album,
trackName: track);
}
else if (!string.IsNullOrWhiteSpace(username))
{
return repo.Count(username: username, from: DateTime.Now.ToUniversalTime().Date,
artistName: artist,
albumName: album,
trackName: track);
}
else
{
throw new ArgumentNullException("user");
}
}
}
}