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

@ -0,0 +1,48 @@
#region Copyright
// /************************************************************************
// Copyright (c) 2016 Jamie Rees
// File: ApplicationSettingsException.cs
// Created By: Jamie Rees
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
// ************************************************************************/
#endregion
using System;
namespace PlexRequests.Helpers.Exceptions
{
public class ApplicationSettingsException : Exception
{
public ApplicationSettingsException(string message) : base(message)
{
}
public ApplicationSettingsException(string message, Exception innerException) : base(message, innerException)
{
}
public ApplicationSettingsException()
{
}
}
}

View file

@ -47,6 +47,7 @@
</ItemGroup>
<ItemGroup>
<Compile Include="AssemblyHelper.cs" />
<Compile Include="Exceptions\ApplicationSettingsException.cs" />
<Compile Include="ICacheProvider.cs" />
<Compile Include="LoggingHelper.cs" />
<Compile Include="MemoryCacheProvider.cs" />
@ -59,6 +60,7 @@
<ItemGroup>
<None Include="packages.config" />
</ItemGroup>
<ItemGroup />
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.

View file

@ -1,5 +1,7 @@
using System;
using PlexRequests.Helpers.Exceptions;
namespace PlexRequests.Helpers
{
public static class UriHelper
@ -7,6 +9,10 @@ namespace PlexRequests.Helpers
public static Uri ReturnUri(this string val)
{
if (val == null)
{
throw new ApplicationSettingsException("The URI is null, please check your settings to make sure you have configured the applications correctly.");
}
try
{
var uri = new UriBuilder();
@ -53,6 +59,10 @@ namespace PlexRequests.Helpers
/// <exception cref="System.Exception"></exception>
public static Uri ReturnUri(this string val, int port)
{
if (val == null)
{
throw new ApplicationSettingsException("The URI is null, please check your settings to make sure you have configured the applications correctly.");
}
try
{
var uri = new UriBuilder();
@ -65,7 +75,7 @@ namespace PlexRequests.Helpers
uri = new UriBuilder(Uri.UriSchemeHttp, split[2], port, "/" + split[3]);
}
else
uri = new UriBuilder(new Uri(string.Format("{0}:{1}", val, port)));
uri = new UriBuilder(new Uri($"{val}:{port}"));
}
else if (val.StartsWith("https://", StringComparison.Ordinal))
{