#96 Email notification test button (others to come)

This commit is contained in:
Drewster727 2016-03-27 23:45:52 -05:00
parent 085c46ce43
commit 4b3f79b4a8
9 changed files with 134 additions and 18 deletions

View file

@ -51,6 +51,7 @@ using PlexRequests.Store.Models;
using PlexRequests.Store.Repository;
using PlexRequests.UI.Helpers;
using PlexRequests.UI.Models;
using System;
namespace PlexRequests.UI.Modules
{
@ -139,6 +140,7 @@ namespace PlexRequests.UI.Modules
Get["/emailnotification"] = _ => EmailNotifications();
Post["/emailnotification"] = _ => SaveEmailNotifications();
Post["/testemailnotification"] = _ => TestEmailNotifications();
Get["/status"] = _ => Status();
Get["/pushbulletnotification"] = _ => PushbulletNotifications();
@ -372,6 +374,19 @@ namespace PlexRequests.UI.Modules
return View["EmailNotifications", settings];
}
private Response TestEmailNotifications()
{
var settings = this.Bind<EmailNotificationSettings>();
var notificationModel = new NotificationModel
{
NotificationType = NotificationType.Test,
DateTime = DateTime.Now
};
NotificationService.Publish(notificationModel, settings);
Log.Info("Sent email notification test");
return Response.AsJson(new JsonResponseModel { Result = true, Message = "Successfully sent a test Email Notification!" });
}
private Response SaveEmailNotifications()
{
var settings = this.Bind<EmailNotificationSettings>();