Some error handling and ensure we are an admin to delete requests.

Also started on the approval of everything
This commit is contained in:
tidusjar 2016-03-08 14:26:26 +00:00
commit 0942bfcbcc
18 changed files with 436 additions and 58 deletions

View file

@ -27,6 +27,8 @@
using System.Collections.Generic;
using System.Linq;
using NLog;
using PlexRequests.Api;
using PlexRequests.Core;
using PlexRequests.Core.SettingModels;
@ -44,9 +46,10 @@ namespace PlexRequests.Services
RequestService = request;
}
private ISettingsService<PlexSettings> Plex { get; }
private ISettingsService<AuthenticationSettings> Auth { get; }
private ISettingsService<PlexSettings> Plex { get; }
private ISettingsService<AuthenticationSettings> Auth { get; }
private IRequestService RequestService { get; }
private static Logger Log = LogManager.GetCurrentClassLogger();
public void CheckAndUpdateAll(long check)
@ -54,6 +57,18 @@ namespace PlexRequests.Services
var plexSettings = Plex.GetSettings();
var authSettings = Auth.GetSettings();
var requests = RequestService.GetAll();
if (plexSettings.Ip == null || authSettings.PlexAuthToken == null || requests == null)
{
Log.Warn("A setting is null, Ensure Plex is configured correctly, and we have a Plex Auth token.");
return;
}
if (!requests.Any())
{
Log.Info("We have no requests to check if they are available on Plex.");
return;
}
var api = new PlexApi();
var modifiedModel = new List<RequestedModel>();
@ -67,7 +82,7 @@ namespace PlexRequests.Services
modifiedModel.Add(originalRequest);
}
RequestService.BatchUpdate(modifiedModel);
RequestService.BatchUpdate(modifiedModel);
}
}
}