aboutsummaryrefslogtreecommitdiff
path: root/MediaBrowser.Server.Implementations/Persistence/SqliteNotificationsRepository.cs
diff options
context:
space:
mode:
Diffstat (limited to 'MediaBrowser.Server.Implementations/Persistence/SqliteNotificationsRepository.cs')
-rw-r--r--MediaBrowser.Server.Implementations/Persistence/SqliteNotificationsRepository.cs28
1 files changed, 10 insertions, 18 deletions
diff --git a/MediaBrowser.Server.Implementations/Persistence/SqliteNotificationsRepository.cs b/MediaBrowser.Server.Implementations/Persistence/SqliteNotificationsRepository.cs
index 7b15467e0..aef8fc03f 100644
--- a/MediaBrowser.Server.Implementations/Persistence/SqliteNotificationsRepository.cs
+++ b/MediaBrowser.Server.Implementations/Persistence/SqliteNotificationsRepository.cs
@@ -78,30 +78,22 @@ namespace MediaBrowser.Server.Implementations.Persistence
/// <returns>NotificationResult.</returns>
public NotificationResult GetNotifications(NotificationQuery query)
{
- var whereClause = string.Empty;
-
var result = new NotificationResult();
using (var cmd = _connection.CreateCommand())
{
- if (query.IsRead.HasValue || query.UserId.HasValue)
- {
- var clauses = new List<string>();
+ var clauses = new List<string>();
- if (query.IsRead.HasValue)
- {
- clauses.Add("IsRead=@IsRead");
- cmd.Parameters.Add(cmd, "@IsRead", DbType.Boolean).Value = query.IsRead.Value;
- }
+ if (query.IsRead.HasValue)
+ {
+ clauses.Add("IsRead=@IsRead");
+ cmd.Parameters.Add(cmd, "@IsRead", DbType.Boolean).Value = query.IsRead.Value;
+ }
- if (query.UserId.HasValue)
- {
- clauses.Add("UserId=@UserId");
- cmd.Parameters.Add(cmd, "@UserId", DbType.Guid).Value = query.UserId.Value;
- }
+ clauses.Add("UserId=@UserId");
+ cmd.Parameters.Add(cmd, "@UserId", DbType.Guid).Value = query.UserId;
- whereClause = " where " + string.Join(" And ", clauses.ToArray());
- }
+ var whereClause = " where " + string.Join(" And ", clauses.ToArray());
cmd.CommandText = string.Format("select count(Id) from Notifications{0};select Id,UserId,Date,Name,Description,Url,Level,IsRead,Category,RelatedId from Notifications{0} order by IsRead asc, Date desc", whereClause);
@@ -155,7 +147,7 @@ namespace MediaBrowser.Server.Implementations.Persistence
}
result.UnreadCount = levels.Count;
-
+
if (levels.Count > 0)
{
result.MaxUnreadNotificationLevel = levels.Max();