浏览代码

Modified GetNotifications.

Gareth O'Brien 11 年之前
父节点
当前提交
d90cd9c386
共有 2 个文件被更改,包括 21 次插入2 次删除
  1. 17 0
      Foghorn.Core/ModelAssemblerExtensions.cs
  2. 4 2
      Foghorn.WcfService/FoghornService.cs

+ 17 - 0
Foghorn.Core/ModelAssemblerExtensions.cs

@@ -25,6 +25,23 @@ namespace Foghorn.Core
         static partial void OnDto(this SendingApplication entity, SendingApplicationDto dto)
         {
             dto.NotificationTypes = (List<NotificationTypeDto>) entity.NotificationTypes.ToDtos();
+            dto.Subscribers = (List<SubscriberDto>) entity.Subscribers.ToDtos();
         }
     }
+
+    public partial class NotificationAssembler
+    {
+        static partial void OnDto(this Notification entity, NotificationDto dto)
+        {
+            dto.SentToSubscribers = (List<SubscriberDto>) entity.SentToSubscribers.ToDtos();
+        }
+    }
+
+//    public partial class SubscriberAssembler
+//    {
+//        static partial void OnDto(this Subscriber entity, SubscriberDto dto)
+//        {
+//            dto.SendingApplication = entity.SendingApplication.ToDto();
+//        }
+//    }
 }

+ 4 - 2
Foghorn.WcfService/FoghornService.cs

@@ -153,9 +153,11 @@ namespace Foghorn.WcfService
             return DataContext.Subscribers.ToDtos();
         }
 
-        public ICollection<NotificationDto> GetNotifications(string sendingApplicationName)
+        public ICollection<NotificationDto> GetNotifications(string subscriberId)
         {
-            return DataContext.Notifications.ToDtos();
+            var subscriberIdGuid = new Guid(subscriberId);
+            var subscriber = DataContext.Subscribers.FirstOrDefault(x => x.SubscriberId == subscriberIdGuid);
+            return subscriber != null ? subscriber.NotificationsSent.ToDtos() : new List<NotificationDto>();
         }
 
         public SendingApplicationDto GetSendingApplication(string sendingApplicationName)