Gareth O'Brien лет назад: 11
Родитель
Сommit
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)