Пример #1
0
 private async Task <Notification> Create(Protocols.Common.NotificationCreate notification)
 {
     try
     {
         return(await _mongoDbNotification.UpsertAsync(Builders <Notification> .Filter.Eq(x => x.Region, notification.Region), notification.ToModel()));
     }
     catch (MongoWriteException)
     {
         throw new DeveloperException(Code.ResultCode.UsingNotificationId);
     }
 }
Пример #2
0
        private async Task <Notification> Create(Protocols.Common.NotificationCreate notification)
        {
            try
            {
                var sourceId = await GetSourceId(notification.CrawlingType, notification.BoardName);

                return(await _mongoDbNotification.UpsertAsync(GetFilterDefinition(sourceId, notification.CrawlingType, notification.Type),
                                                              notification.ToModel(sourceId)));
            }
            catch (MongoWriteException)
            {
                throw new DeveloperException(ResultCode.UsingNotificationId);
            }
        }
Пример #3
0
 public static Notification ToModel(this Protocols.Common.NotificationCreate notification, string sourceId = "")
 {
     return(new Notification
     {
         Type = notification.Type,
         Name = notification.Name,
         HookUrl = notification.HookUrl,
         Channel = notification.Channel,
         IconUrl = notification.IconUrl,
         SourceId = sourceId,
         CrawlingType = notification.CrawlingType,
         Keyword = notification.Keyword,
         FilterDayOfWeeks = notification.FilterDayOfWeeks,
         FilterStartTime = notification.FilterStartTime,
         FilterEndTime = notification.FilterEndTime
     });
 }