From 16b58256c4bee95f95e3deb2a1458235c3f4bb7c Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Sun, 7 Jul 2013 01:41:28 -0400 Subject: [PATCH] updated nuget --- .../Notifications/NotificationQuery.cs | 2 +- .../SqliteNotificationsRepository.cs | 30 +++++++------------ Nuget/MediaBrowser.Common.Internal.nuspec | 4 +-- Nuget/MediaBrowser.Common.nuspec | 2 +- Nuget/MediaBrowser.Server.Core.nuspec | 4 +-- 5 files changed, 17 insertions(+), 25 deletions(-) diff --git a/MediaBrowser.Model/Notifications/NotificationQuery.cs b/MediaBrowser.Model/Notifications/NotificationQuery.cs index 39a7326a6d..a252e25122 100644 --- a/MediaBrowser.Model/Notifications/NotificationQuery.cs +++ b/MediaBrowser.Model/Notifications/NotificationQuery.cs @@ -4,7 +4,7 @@ namespace MediaBrowser.Model.Notifications { public class NotificationQuery { - public Guid? UserId { get; set; } + public Guid UserId { get; set; } public bool? IsRead { get; set; } diff --git a/MediaBrowser.Server.Implementations/Persistence/SqliteNotificationsRepository.cs b/MediaBrowser.Server.Implementations/Persistence/SqliteNotificationsRepository.cs index 7b15467e09..aef8fc03fc 100644 --- a/MediaBrowser.Server.Implementations/Persistence/SqliteNotificationsRepository.cs +++ b/MediaBrowser.Server.Implementations/Persistence/SqliteNotificationsRepository.cs @@ -78,31 +78,23 @@ namespace MediaBrowser.Server.Implementations.Persistence /// NotificationResult. 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(); + + if (query.IsRead.HasValue) { - var clauses = new List(); - - 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; - } - - whereClause = " where " + string.Join(" And ", clauses.ToArray()); + clauses.Add("IsRead=@IsRead"); + cmd.Parameters.Add(cmd, "@IsRead", DbType.Boolean).Value = query.IsRead.Value; } + clauses.Add("UserId=@UserId"); + cmd.Parameters.Add(cmd, "@UserId", DbType.Guid).Value = query.UserId; + + 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); using (var reader = cmd.ExecuteReader(CommandBehavior.SequentialAccess)) @@ -155,7 +147,7 @@ namespace MediaBrowser.Server.Implementations.Persistence } result.UnreadCount = levels.Count; - + if (levels.Count > 0) { result.MaxUnreadNotificationLevel = levels.Max(); diff --git a/Nuget/MediaBrowser.Common.Internal.nuspec b/Nuget/MediaBrowser.Common.Internal.nuspec index 5f516844a6..e36d29e206 100644 --- a/Nuget/MediaBrowser.Common.Internal.nuspec +++ b/Nuget/MediaBrowser.Common.Internal.nuspec @@ -2,7 +2,7 @@ MediaBrowser.Common.Internal - 3.0.139 + 3.0.140 MediaBrowser.Common.Internal Luke ebr,Luke,scottisafool @@ -12,7 +12,7 @@ Contains common components shared by Media Browser Theater and Media Browser Server. Not intended for plugin developer consumption. Copyright © Media Browser 2013 - + diff --git a/Nuget/MediaBrowser.Common.nuspec b/Nuget/MediaBrowser.Common.nuspec index a466e90581..29e8607853 100644 --- a/Nuget/MediaBrowser.Common.nuspec +++ b/Nuget/MediaBrowser.Common.nuspec @@ -2,7 +2,7 @@ MediaBrowser.Common - 3.0.139 + 3.0.140 MediaBrowser.Common Media Browser Team ebr,Luke,scottisafool diff --git a/Nuget/MediaBrowser.Server.Core.nuspec b/Nuget/MediaBrowser.Server.Core.nuspec index f2684f93b6..7f41aed49f 100644 --- a/Nuget/MediaBrowser.Server.Core.nuspec +++ b/Nuget/MediaBrowser.Server.Core.nuspec @@ -2,7 +2,7 @@ MediaBrowser.Server.Core - 3.0.139 + 3.0.140 Media Browser.Server.Core Media Browser Team ebr,Luke,scottisafool @@ -12,7 +12,7 @@ Contains core components required to build plugins for Media Browser Server. Copyright © Media Browser 2013 - +