|
|
@ -18,11 +18,17 @@ namespace NzbDrone.Api.Notifications
|
|
|
|
_notificationService = notificationService;
|
|
|
|
_notificationService = notificationService;
|
|
|
|
|
|
|
|
|
|
|
|
GetResourceAll = GetAll;
|
|
|
|
GetResourceAll = GetAll;
|
|
|
|
|
|
|
|
GetResourceById = GetNotification;
|
|
|
|
CreateResource = Create;
|
|
|
|
CreateResource = Create;
|
|
|
|
UpdateResource = Update;
|
|
|
|
UpdateResource = Update;
|
|
|
|
DeleteResource = DeleteNotification;
|
|
|
|
DeleteResource = DeleteNotification;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private NotificationResource GetNotification(int id)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
return _notificationService.Get(id).InjectTo<NotificationResource>();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private List<NotificationResource> GetAll()
|
|
|
|
private List<NotificationResource> GetAll()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
var notifications = _notificationService.All();
|
|
|
|
var notifications = _notificationService.All();
|
|
|
@ -44,13 +50,13 @@ namespace NzbDrone.Api.Notifications
|
|
|
|
|
|
|
|
|
|
|
|
private int Create(NotificationResource notificationResource)
|
|
|
|
private int Create(NotificationResource notificationResource)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
var notification = GetNotification(notificationResource);
|
|
|
|
var notification = ConvertToNotification(notificationResource);
|
|
|
|
return _notificationService.Create(notification).Id;
|
|
|
|
return _notificationService.Create(notification).Id;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void Update(NotificationResource notificationResource)
|
|
|
|
private void Update(NotificationResource notificationResource)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
var notification = GetNotification(notificationResource);
|
|
|
|
var notification = ConvertToNotification(notificationResource);
|
|
|
|
notification.Id = notificationResource.Id;
|
|
|
|
notification.Id = notificationResource.Id;
|
|
|
|
_notificationService.Update(notification);
|
|
|
|
_notificationService.Update(notification);
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -60,7 +66,7 @@ namespace NzbDrone.Api.Notifications
|
|
|
|
_notificationService.Delete(id);
|
|
|
|
_notificationService.Delete(id);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private Notification GetNotification(NotificationResource notificationResource)
|
|
|
|
private Notification ConvertToNotification(NotificationResource notificationResource)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
var notification = _notificationService.Schema()
|
|
|
|
var notification = _notificationService.Schema()
|
|
|
|
.SingleOrDefault(i =>
|
|
|
|
.SingleOrDefault(i =>
|
|
|
|