mirror of
https://github.com/Ombi-app/Ombi.git
synced 2025-07-11 07:46:05 -07:00
merge
This commit is contained in:
commit
0e2f5bbf98
50 changed files with 1832 additions and 176 deletions
|
@ -1,14 +1,37 @@
|
||||||
using System;
|
#region Copyright
|
||||||
using System.Collections.Generic;
|
// /************************************************************************
|
||||||
using System.Linq;
|
// Copyright (c) 2016 Jamie Rees
|
||||||
using System.Text;
|
// File: MovieBase.cs
|
||||||
using System.Threading.Tasks;
|
// 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 RequestPlex.Helpers;
|
||||||
|
|
||||||
namespace RequestPlex.Api
|
namespace RequestPlex.Api
|
||||||
{
|
{
|
||||||
public abstract class MovieBase
|
public abstract class MovieBase
|
||||||
{
|
{
|
||||||
protected string ApiKey = "b8eabaf5608b88d0298aa189dd90bf00";
|
private static readonly string Encrypted = "0T3QNSseexLO7n7UPiJvl70Y+KKnvbeTlsusl7Kwq0hPH0BHOuFNGwksNCjkwqWedyDdI/MJeUR4wtL4bIl0Z+//uHXEaYM/4H2pjeLbH5EWdUe5TTj1AhaIR5PQweamvcienRyFD/3YPCC/+qL5mHkKXBkPumMod3Zb/4yN0Ik=";
|
||||||
|
protected string ApiKey = StringCipher.Decrypt(Encrypted, "ApiKey");
|
||||||
protected string Url = "http://api.themoviedb.org/3";
|
protected string Url = "http://api.themoviedb.org/3";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,7 +25,7 @@ namespace RequestPlex.Api
|
||||||
Method = Method.POST,
|
Method = Method.POST,
|
||||||
};
|
};
|
||||||
|
|
||||||
request.AddHeader("X-Plex-Client-Identifier", "Test213");
|
request.AddHeader("X-Plex-Client-Identifier", "Test213"); // TODO need something unique to the users version/installation
|
||||||
request.AddHeader("X-Plex-Product", "Request Plex");
|
request.AddHeader("X-Plex-Product", "Request Plex");
|
||||||
request.AddHeader("X-Plex-Version", "0.0.1");
|
request.AddHeader("X-Plex-Version", "0.0.1");
|
||||||
request.AddHeader("Content-Type", "application/json");
|
request.AddHeader("Content-Type", "application/json");
|
||||||
|
|
|
@ -77,6 +77,10 @@
|
||||||
<Project>{95834072-A675-415D-AA8F-877C91623810}</Project>
|
<Project>{95834072-A675-415D-AA8F-877C91623810}</Project>
|
||||||
<Name>RequestPlex.Api.Interfaces</Name>
|
<Name>RequestPlex.Api.Interfaces</Name>
|
||||||
</ProjectReference>
|
</ProjectReference>
|
||||||
|
<ProjectReference Include="..\RequestPlex.Helpers\RequestPlex.Helpers.csproj">
|
||||||
|
<Project>{1252336D-42A3-482A-804C-836E60173DFA}</Project>
|
||||||
|
<Name>RequestPlex.Helpers</Name>
|
||||||
|
</ProjectReference>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup />
|
<ItemGroup />
|
||||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||||
|
|
|
@ -5,6 +5,7 @@ using TMDbLib.Client;
|
||||||
using TMDbLib.Objects.General;
|
using TMDbLib.Objects.General;
|
||||||
using TMDbLib.Objects.Movies;
|
using TMDbLib.Objects.Movies;
|
||||||
using TMDbLib.Objects.Search;
|
using TMDbLib.Objects.Search;
|
||||||
|
using TMDbLib.Objects.TvShows;
|
||||||
|
|
||||||
namespace RequestPlex.Api
|
namespace RequestPlex.Api
|
||||||
{
|
{
|
||||||
|
@ -39,5 +40,17 @@ namespace RequestPlex.Api
|
||||||
var movies = await Client.GetMovieList(MovieListType.Upcoming);
|
var movies = await Client.GetMovieList(MovieListType.Upcoming);
|
||||||
return movies.Results;
|
return movies.Results;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public async Task<Movie> GetMovieInformation(int tmdbId)
|
||||||
|
{
|
||||||
|
var movies = await Client.GetMovie(tmdbId);
|
||||||
|
return movies;
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<TvShow> GetTvShowInformation(int tmdbId)
|
||||||
|
{
|
||||||
|
var show = await Client.GetTvShow(tmdbId);
|
||||||
|
return show;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
35
RequestPlex.Core/ISettingsService.cs
Normal file
35
RequestPlex.Core/ISettingsService.cs
Normal file
|
@ -0,0 +1,35 @@
|
||||||
|
#region Copyright
|
||||||
|
// /************************************************************************
|
||||||
|
// Copyright (c) 2016 Jamie Rees
|
||||||
|
// File: ISettingsService.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
|
||||||
|
namespace RequestPlex.Core
|
||||||
|
{
|
||||||
|
public interface ISettingsService<T>
|
||||||
|
{
|
||||||
|
T GetSettings();
|
||||||
|
bool SaveSettings(T model);
|
||||||
|
bool Delete(T model);
|
||||||
|
}
|
||||||
|
}
|
|
@ -41,6 +41,14 @@
|
||||||
<HintPath>..\packages\Nancy.Authentication.Forms.1.4.1\lib\net40\Nancy.Authentication.Forms.dll</HintPath>
|
<HintPath>..\packages\Nancy.Authentication.Forms.1.4.1\lib\net40\Nancy.Authentication.Forms.dll</HintPath>
|
||||||
<Private>True</Private>
|
<Private>True</Private>
|
||||||
</Reference>
|
</Reference>
|
||||||
|
<Reference Include="Newtonsoft.Json, Version=8.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
|
||||||
|
<HintPath>..\packages\Newtonsoft.Json.8.0.2\lib\net45\Newtonsoft.Json.dll</HintPath>
|
||||||
|
<Private>True</Private>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="Omu.ValueInjecter, Version=3.1.1.0, Culture=neutral, PublicKeyToken=c7694541b0ac80e4, processorArchitecture=MSIL">
|
||||||
|
<HintPath>..\packages\valueinjecter.3.1.1.2\lib\net40\Omu.ValueInjecter.dll</HintPath>
|
||||||
|
<Private>True</Private>
|
||||||
|
</Reference>
|
||||||
<Reference Include="System" />
|
<Reference Include="System" />
|
||||||
<Reference Include="System.Core" />
|
<Reference Include="System.Core" />
|
||||||
<Reference Include="System.Xml.Linq" />
|
<Reference Include="System.Xml.Linq" />
|
||||||
|
@ -49,9 +57,17 @@
|
||||||
<Reference Include="System.Data" />
|
<Reference Include="System.Data" />
|
||||||
<Reference Include="System.Net.Http" />
|
<Reference Include="System.Net.Http" />
|
||||||
<Reference Include="System.Xml" />
|
<Reference Include="System.Xml" />
|
||||||
|
<Reference Include="TMDbLib">
|
||||||
|
<HintPath>..\packages\TMDbLib.0.9.0.0-alpha\lib\net45\TMDbLib.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<Compile Include="ISettingsService.cs" />
|
||||||
|
<Compile Include="RequestService.cs" />
|
||||||
|
<Compile Include="SettingModels\RequestPlexSettings.cs" />
|
||||||
|
<Compile Include="SettingModels\Settings.cs" />
|
||||||
<Compile Include="SettingsService.cs" />
|
<Compile Include="SettingsService.cs" />
|
||||||
|
<Compile Include="SettingsServiceV2.cs" />
|
||||||
<Compile Include="Setup.cs" />
|
<Compile Include="Setup.cs" />
|
||||||
<Compile Include="UserIdentity.cs" />
|
<Compile Include="UserIdentity.cs" />
|
||||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||||
|
@ -61,6 +77,14 @@
|
||||||
<None Include="packages.config" />
|
<None Include="packages.config" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<ProjectReference Include="..\RequestPlex.Api\RequestPlex.Api.csproj">
|
||||||
|
<Project>{8CB8D235-2674-442D-9C6A-35FCAEEB160D}</Project>
|
||||||
|
<Name>RequestPlex.Api</Name>
|
||||||
|
</ProjectReference>
|
||||||
|
<ProjectReference Include="..\RequestPlex.Helpers\RequestPlex.Helpers.csproj">
|
||||||
|
<Project>{1252336D-42A3-482A-804C-836E60173DFA}</Project>
|
||||||
|
<Name>RequestPlex.Helpers</Name>
|
||||||
|
</ProjectReference>
|
||||||
<ProjectReference Include="..\RequestPlex.Store\RequestPlex.Store.csproj">
|
<ProjectReference Include="..\RequestPlex.Store\RequestPlex.Store.csproj">
|
||||||
<Project>{92433867-2B7B-477B-A566-96C382427525}</Project>
|
<Project>{92433867-2B7B-477B-A566-96C382427525}</Project>
|
||||||
<Name>RequestPlex.Store</Name>
|
<Name>RequestPlex.Store</Name>
|
||||||
|
|
65
RequestPlex.Core/RequestService.cs
Normal file
65
RequestPlex.Core/RequestService.cs
Normal file
|
@ -0,0 +1,65 @@
|
||||||
|
#region Copyright
|
||||||
|
// /************************************************************************
|
||||||
|
// Copyright (c) 2016 Jamie Rees
|
||||||
|
// File: RequestService.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.Linq;
|
||||||
|
|
||||||
|
using RequestPlex.Store;
|
||||||
|
|
||||||
|
namespace RequestPlex.Core
|
||||||
|
{
|
||||||
|
public class RequestService
|
||||||
|
{
|
||||||
|
public RequestService(ISqliteConfiguration db, IRepository<RequestedModel> repo)
|
||||||
|
{
|
||||||
|
Db = db;
|
||||||
|
Repo = repo;
|
||||||
|
}
|
||||||
|
private ISqliteConfiguration Db { get; set; }
|
||||||
|
private IRepository<RequestedModel> Repo { get; set; }
|
||||||
|
public void AddRequest(int tmdbid, RequestType type)
|
||||||
|
{
|
||||||
|
var model = new RequestedModel
|
||||||
|
{
|
||||||
|
Tmdbid = tmdbid,
|
||||||
|
Type = type
|
||||||
|
};
|
||||||
|
|
||||||
|
Repo.Insert(model);
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool CheckRequest(int tmdbid)
|
||||||
|
{
|
||||||
|
return Repo.GetAll().Any(x => x.Tmdbid == tmdbid);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void DeleteRequest(int tmdbId)
|
||||||
|
{
|
||||||
|
var entity = Repo.GetAll().FirstOrDefault(x => x.Tmdbid == tmdbId);
|
||||||
|
Repo.Delete(entity);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
35
RequestPlex.Core/SettingModels/RequestPlexSettings.cs
Normal file
35
RequestPlex.Core/SettingModels/RequestPlexSettings.cs
Normal file
|
@ -0,0 +1,35 @@
|
||||||
|
#region Copyright
|
||||||
|
// /************************************************************************
|
||||||
|
// Copyright (c) 2016 Jamie Rees
|
||||||
|
// File: RequestPlexSettings.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
|
||||||
|
namespace RequestPlex.Core.SettingModels
|
||||||
|
{
|
||||||
|
public class RequestPlexSettings : Settings
|
||||||
|
{
|
||||||
|
public int Port { get; set; }
|
||||||
|
public bool UserAuthentication { get; set; }
|
||||||
|
public string PlexAuthToken { get; set; }
|
||||||
|
}
|
||||||
|
}
|
33
RequestPlex.Core/SettingModels/Settings.cs
Normal file
33
RequestPlex.Core/SettingModels/Settings.cs
Normal file
|
@ -0,0 +1,33 @@
|
||||||
|
#region Copyright
|
||||||
|
// /************************************************************************
|
||||||
|
// Copyright (c) 2016 Jamie Rees
|
||||||
|
// File: Settings.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
|
||||||
|
namespace RequestPlex.Core.SettingModels
|
||||||
|
{
|
||||||
|
public class Settings
|
||||||
|
{
|
||||||
|
public int Id { get; set; }
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,32 +1,41 @@
|
||||||
using System;
|
#region Copyright
|
||||||
using System.Collections.Generic;
|
// /************************************************************************
|
||||||
|
// Copyright (c) 2016 Jamie Rees
|
||||||
|
// File: SettingsService.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;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
using Mono.Data.Sqlite;
|
using Mono.Data.Sqlite;
|
||||||
|
|
||||||
|
using RequestPlex.Api;
|
||||||
using RequestPlex.Store;
|
using RequestPlex.Store;
|
||||||
|
|
||||||
namespace RequestPlex.Core
|
namespace RequestPlex.Core
|
||||||
{
|
{
|
||||||
public class SettingsService
|
public class SettingsService
|
||||||
{
|
{
|
||||||
public void SaveSettings(SettingsModel model)
|
|
||||||
{
|
|
||||||
var db = new DbConfiguration(new SqliteFactory());
|
|
||||||
var repo = new GenericRepository<SettingsModel>(db);
|
|
||||||
|
|
||||||
var existingSettings = repo.GetAll().FirstOrDefault();
|
|
||||||
if (existingSettings != null)
|
|
||||||
{
|
|
||||||
existingSettings = model;
|
|
||||||
repo.Update(existingSettings);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
repo.Insert(model);
|
|
||||||
}
|
|
||||||
|
|
||||||
public SettingsModel GetSettings()
|
public SettingsModel GetSettings()
|
||||||
{
|
{
|
||||||
|
@ -40,12 +49,39 @@ namespace RequestPlex.Core
|
||||||
|
|
||||||
public void AddRequest(int tmdbid, RequestType type)
|
public void AddRequest(int tmdbid, RequestType type)
|
||||||
{
|
{
|
||||||
var model = new RequestedModel
|
var api = new TheMovieDbApi();
|
||||||
|
var model = new RequestedModel();
|
||||||
|
if (type == RequestType.Movie)
|
||||||
{
|
{
|
||||||
Tmdbid = tmdbid,
|
var movieInfo = api.GetMovieInformation(tmdbid).Result;
|
||||||
Type = type
|
|
||||||
};
|
|
||||||
|
|
||||||
|
model = new RequestedModel
|
||||||
|
{
|
||||||
|
Tmdbid = movieInfo.Id,
|
||||||
|
Type = type,
|
||||||
|
Overview = movieInfo.Overview,
|
||||||
|
ImdbId = movieInfo.ImdbId,
|
||||||
|
PosterPath = "http://image.tmdb.org/t/p/w150/" + movieInfo.PosterPath,
|
||||||
|
Title = movieInfo.Title,
|
||||||
|
ReleaseDate = movieInfo.ReleaseDate ?? DateTime.MinValue,
|
||||||
|
Status = movieInfo.Status
|
||||||
|
};
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
var showInfo = api.GetTvShowInformation(tmdbid).Result;
|
||||||
|
|
||||||
|
model = new RequestedModel
|
||||||
|
{
|
||||||
|
Tmdbid = showInfo.Id,
|
||||||
|
Type = type,
|
||||||
|
Overview = showInfo.Overview,
|
||||||
|
PosterPath = "http://image.tmdb.org/t/p/w150/" + showInfo.PosterPath,
|
||||||
|
Title = showInfo.Name,
|
||||||
|
ReleaseDate = showInfo.FirstAirDate ?? DateTime.MinValue,
|
||||||
|
Status = showInfo.Status
|
||||||
|
};
|
||||||
|
}
|
||||||
var db = new DbConfiguration(new SqliteFactory());
|
var db = new DbConfiguration(new SqliteFactory());
|
||||||
var repo = new GenericRepository<RequestedModel>(db);
|
var repo = new GenericRepository<RequestedModel>(db);
|
||||||
|
|
||||||
|
|
114
RequestPlex.Core/SettingsServiceV2.cs
Normal file
114
RequestPlex.Core/SettingsServiceV2.cs
Normal file
|
@ -0,0 +1,114 @@
|
||||||
|
#region Copyright
|
||||||
|
// /************************************************************************
|
||||||
|
// Copyright (c) 2016 Jamie Rees
|
||||||
|
// File: SettingsServiceV2.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 Newtonsoft.Json;
|
||||||
|
|
||||||
|
using Omu.ValueInjecter;
|
||||||
|
|
||||||
|
using RequestPlex.Core.SettingModels;
|
||||||
|
using RequestPlex.Helpers;
|
||||||
|
using RequestPlex.Store;
|
||||||
|
using RequestPlex.Store.Models;
|
||||||
|
|
||||||
|
namespace RequestPlex.Core
|
||||||
|
{
|
||||||
|
public class SettingsServiceV2<T> : ISettingsService<T>
|
||||||
|
where T : Settings, new()
|
||||||
|
{
|
||||||
|
|
||||||
|
public SettingsServiceV2(ISettingsRepository repo)
|
||||||
|
{
|
||||||
|
Repo = repo;
|
||||||
|
EntityName = typeof(T).Name;
|
||||||
|
}
|
||||||
|
|
||||||
|
private ISettingsRepository Repo { get; set; }
|
||||||
|
private string EntityName { get; set; }
|
||||||
|
|
||||||
|
public T GetSettings()
|
||||||
|
{
|
||||||
|
var result = Repo.Get(EntityName);
|
||||||
|
if (result == null)
|
||||||
|
{
|
||||||
|
return new T();
|
||||||
|
}
|
||||||
|
result.Content = DecryptSettings(result);
|
||||||
|
var obj = string.IsNullOrEmpty(result.Content) ? null : JsonConvert.DeserializeObject<T>(result.Content, SerializerSettings.Settings);
|
||||||
|
|
||||||
|
var model = obj;
|
||||||
|
|
||||||
|
return model;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool SaveSettings(T model)
|
||||||
|
{
|
||||||
|
var entity = Repo.Get(EntityName);
|
||||||
|
|
||||||
|
if (entity == null)
|
||||||
|
{
|
||||||
|
var newEntity = model;
|
||||||
|
|
||||||
|
var settings = new GlobalSettings { SettingsName = EntityName, Content = JsonConvert.SerializeObject(newEntity, SerializerSettings.Settings) };
|
||||||
|
settings.Content = EncryptSettings(settings);
|
||||||
|
var insertResult = Repo.Insert(settings);
|
||||||
|
|
||||||
|
return insertResult != long.MinValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
var modified = model;
|
||||||
|
modified.Id = entity.Id;
|
||||||
|
|
||||||
|
var globalSettings = new GlobalSettings { SettingsName = EntityName, Content = JsonConvert.SerializeObject(modified, SerializerSettings.Settings), Id = entity.Id };
|
||||||
|
globalSettings.Content = EncryptSettings(globalSettings);
|
||||||
|
var result = Repo.Update(globalSettings);
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool Delete(T model)
|
||||||
|
{
|
||||||
|
var entity = Repo.Get(EntityName);
|
||||||
|
if (entity != null)
|
||||||
|
{
|
||||||
|
return Repo.Delete(entity);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Entity does not exist so nothing to delete
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
private string EncryptSettings(GlobalSettings settings)
|
||||||
|
{
|
||||||
|
return StringCipher.Encrypt(settings.Content, settings.SettingsName);
|
||||||
|
}
|
||||||
|
|
||||||
|
private string DecryptSettings(GlobalSettings settings)
|
||||||
|
{
|
||||||
|
return StringCipher.Decrypt(settings.Content, settings.SettingsName);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,8 +1,32 @@
|
||||||
using System;
|
#region Copyright
|
||||||
|
// /************************************************************************
|
||||||
|
// Copyright (c) 2016 Jamie Rees
|
||||||
|
// File: UserMapper.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;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
|
||||||
using Mono.Data.Sqlite;
|
|
||||||
|
|
||||||
using Nancy;
|
using Nancy;
|
||||||
using Nancy.Authentication.Forms;
|
using Nancy.Authentication.Forms;
|
||||||
using Nancy.Security;
|
using Nancy.Security;
|
||||||
|
@ -13,11 +37,14 @@ namespace RequestPlex.Core
|
||||||
{
|
{
|
||||||
public class UserMapper : IUserMapper
|
public class UserMapper : IUserMapper
|
||||||
{
|
{
|
||||||
|
public UserMapper(ISqliteConfiguration db)
|
||||||
|
{
|
||||||
|
Db = db;
|
||||||
|
}
|
||||||
|
private static ISqliteConfiguration Db { get; set; }
|
||||||
public IUserIdentity GetUserFromIdentifier(Guid identifier, NancyContext context)
|
public IUserIdentity GetUserFromIdentifier(Guid identifier, NancyContext context)
|
||||||
{
|
{
|
||||||
var db = new DbConfiguration(new SqliteFactory());
|
var repo = new UserRepository<UserModel>(Db);
|
||||||
var repo = new UserRepository<UserModel>(db);
|
|
||||||
|
|
||||||
var user = repo.Get(identifier.ToString());
|
var user = repo.Get(identifier.ToString());
|
||||||
|
|
||||||
|
@ -34,8 +61,7 @@ namespace RequestPlex.Core
|
||||||
|
|
||||||
public static Guid? ValidateUser(string username, string password)
|
public static Guid? ValidateUser(string username, string password)
|
||||||
{
|
{
|
||||||
var db = new DbConfiguration(new SqliteFactory());
|
var repo = new UserRepository<UserModel>(Db);
|
||||||
var repo = new UserRepository<UserModel>(db);
|
|
||||||
var users = repo.GetAll();
|
var users = repo.GetAll();
|
||||||
var userRecord = users.FirstOrDefault(u => u.UserName.Equals(username, StringComparison.InvariantCultureIgnoreCase) && u.Password.Equals(password)); // TODO hashing
|
var userRecord = users.FirstOrDefault(u => u.UserName.Equals(username, StringComparison.InvariantCultureIgnoreCase) && u.Password.Equals(password)); // TODO hashing
|
||||||
|
|
||||||
|
@ -49,16 +75,14 @@ namespace RequestPlex.Core
|
||||||
|
|
||||||
public static bool DoUsersExist()
|
public static bool DoUsersExist()
|
||||||
{
|
{
|
||||||
var db = new DbConfiguration(new SqliteFactory());
|
var repo = new UserRepository<UserModel>(Db);
|
||||||
var repo = new UserRepository<UserModel>(db);
|
|
||||||
var users = repo.GetAll();
|
var users = repo.GetAll();
|
||||||
return users.Any();
|
return users.Any();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Guid? CreateUser(string username, string password)
|
public static Guid? CreateUser(string username, string password)
|
||||||
{
|
{
|
||||||
var db = new DbConfiguration(new SqliteFactory());
|
var repo = new UserRepository<UserModel>(Db);
|
||||||
var repo = new UserRepository<UserModel>(db);
|
|
||||||
|
|
||||||
var userModel = new UserModel { UserName = username, User = Guid.NewGuid().ToString(), Password = password };
|
var userModel = new UserModel { UserName = username, User = Guid.NewGuid().ToString(), Password = password };
|
||||||
repo.Insert(userModel);
|
repo.Insert(userModel);
|
||||||
|
|
|
@ -2,4 +2,6 @@
|
||||||
<packages>
|
<packages>
|
||||||
<package id="Nancy" version="1.4.3" targetFramework="net452" />
|
<package id="Nancy" version="1.4.3" targetFramework="net452" />
|
||||||
<package id="Nancy.Authentication.Forms" version="1.4.1" targetFramework="net452" />
|
<package id="Nancy.Authentication.Forms" version="1.4.1" targetFramework="net452" />
|
||||||
|
<package id="Newtonsoft.Json" version="8.0.2" targetFramework="net452" />
|
||||||
|
<package id="valueinjecter" version="3.1.1.2" targetFramework="net452" />
|
||||||
</packages>
|
</packages>
|
66
RequestPlex.Helpers/ICacheProvider.cs
Normal file
66
RequestPlex.Helpers/ICacheProvider.cs
Normal file
|
@ -0,0 +1,66 @@
|
||||||
|
#region Copyright
|
||||||
|
// /************************************************************************
|
||||||
|
// Copyright (c) 2016 Jamie Rees
|
||||||
|
// File: ICacheProvider.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 RequestPlex.Helpers
|
||||||
|
{
|
||||||
|
public interface ICacheProvider
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the item from the cache, if the item is not present
|
||||||
|
/// then we will get that item and store it in the cache.
|
||||||
|
/// </summary>
|
||||||
|
/// <typeparam name="T">Type to store in the cache</typeparam>
|
||||||
|
/// <param name="key">The key</param>
|
||||||
|
/// <param name="itemCallback">The item callback. This will be called if the item is not present in the cache. </param>
|
||||||
|
/// <param name="cacheTime">The amount of time we want to cache the object</param>
|
||||||
|
/// <returns><see cref="T"/></returns>
|
||||||
|
T GetOrSet<T>(string key, Func<T> itemCallback, int cacheTime = 20) where T : class;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the specified item from the cache.
|
||||||
|
/// </summary>
|
||||||
|
/// <typeparam name="T">Type to get from the cache</typeparam>
|
||||||
|
/// <param name="key">The key.</param>
|
||||||
|
/// <returns><see cref="T"/></returns>
|
||||||
|
T Get<T>(string key) where T : class;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Set/Store the specified object in the cache
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="key">The key.</param>
|
||||||
|
/// <param name="data">The object we want to store.</param>
|
||||||
|
/// <param name="cacheTime">The amount of time we want to cache the object.</param>
|
||||||
|
void Set(string key, object data, int cacheTime);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Removes the specified object from the cache.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="key">The key.</param>
|
||||||
|
void Remove(string key);
|
||||||
|
}
|
||||||
|
}
|
105
RequestPlex.Helpers/MemoryCacheProvider.cs
Normal file
105
RequestPlex.Helpers/MemoryCacheProvider.cs
Normal file
|
@ -0,0 +1,105 @@
|
||||||
|
#region Copyright
|
||||||
|
// /************************************************************************
|
||||||
|
// Copyright (c) 2016 Jamie Rees
|
||||||
|
// File: MemoryCacheProvider.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;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Runtime.Caching;
|
||||||
|
|
||||||
|
namespace RequestPlex.Helpers
|
||||||
|
{
|
||||||
|
public class MemoryCacheProvider : ICacheProvider
|
||||||
|
{
|
||||||
|
private ObjectCache Cache => MemoryCache.Default;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the item from the cache, if the item is not present
|
||||||
|
/// then we will get that item and store it in the cache.
|
||||||
|
/// </summary>
|
||||||
|
/// <typeparam name="T">Type to store in the cache.</typeparam>
|
||||||
|
/// <param name="key">The key.</param>
|
||||||
|
/// <param name="itemCallback">The item callback. This will be called if the item is not present in the cache.
|
||||||
|
/// </param>
|
||||||
|
/// <param name="cacheTime">The amount of time we want to cache the object.</param>
|
||||||
|
/// <returns>A copy of the cached object.</returns>
|
||||||
|
/// <remarks>If the <c><![CDATA[Func<T>]]> itemCallback</c> is null and the item is not in the cache it will throw a <see cref="NullReferenceException"/>.
|
||||||
|
/// <para>If you do not want to change the object in the cache (since it's a copy returned and not a reference) you will need to <see cref="Remove"/>
|
||||||
|
/// the cached item and then <see cref="Set"/> it, or just call this method.</para></remarks>
|
||||||
|
public T GetOrSet<T>(string key, Func<T> itemCallback, int cacheTime = 20) where T : class
|
||||||
|
{
|
||||||
|
var item = Get<T>(key);
|
||||||
|
if (item == null)
|
||||||
|
{
|
||||||
|
item = itemCallback();
|
||||||
|
if (item != null)
|
||||||
|
{
|
||||||
|
Set(key, item, cacheTime);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Return a copy, not the stored cache reference
|
||||||
|
// The cached object will not change
|
||||||
|
// If we
|
||||||
|
return item.CloneJson();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the specified item from the cache.
|
||||||
|
/// </summary>
|
||||||
|
/// <typeparam name="T">Type to get from the cache</typeparam>
|
||||||
|
/// <param name="key">The key.</param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public T Get<T>(string key) where T : class
|
||||||
|
{
|
||||||
|
var item = Cache.Get(key) as T;
|
||||||
|
return item;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Set/Store the specified object in the cache
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="key">The key.</param>
|
||||||
|
/// <param name="data">The object we want to store.</param>
|
||||||
|
/// <param name="cacheTime">The amount of time we want to cache the object.</param>
|
||||||
|
public void Set(string key, object data, int cacheTime)
|
||||||
|
{
|
||||||
|
var policy = new CacheItemPolicy { AbsoluteExpiration = DateTime.Now + TimeSpan.FromMinutes(cacheTime) };
|
||||||
|
Cache.Add(new CacheItem(key, data), policy);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Removes the specified object from the cache.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="key">The key.</param>
|
||||||
|
public void Remove(string key)
|
||||||
|
{
|
||||||
|
var keys = Cache.Where(x => x.Key.Contains(key));
|
||||||
|
foreach (var k in keys)
|
||||||
|
{
|
||||||
|
Cache.Remove(k.Key);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
57
RequestPlex.Helpers/ObjectCopier.cs
Normal file
57
RequestPlex.Helpers/ObjectCopier.cs
Normal file
|
@ -0,0 +1,57 @@
|
||||||
|
#region Copyright
|
||||||
|
// /************************************************************************
|
||||||
|
// Copyright (c) 2016 Jamie Rees
|
||||||
|
// File: ObjectCopier.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 Newtonsoft.Json;
|
||||||
|
|
||||||
|
namespace RequestPlex.Helpers
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Provides a method for performing a deep copy of an object.
|
||||||
|
/// Binary Serialization is used to perform the copy.
|
||||||
|
/// </summary>
|
||||||
|
public static class ObjectCopier
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// <para>Initialize inner objects individually</para>
|
||||||
|
/// For example in default constructor some list property initialized with some values,
|
||||||
|
/// but in 'source' these items are cleaned -
|
||||||
|
/// without <c>ObjectCreationHandling.Replace</c> default constructor values will be added to result
|
||||||
|
/// </summary>
|
||||||
|
private static readonly JsonSerializerSettings Settings = new JsonSerializerSettings { ObjectCreationHandling = ObjectCreationHandling.Replace };
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Perform a deep Copy of the object, using Json as a serialisation method.
|
||||||
|
/// </summary>
|
||||||
|
/// <typeparam name="T">The type of object being copied.</typeparam>
|
||||||
|
/// <param name="source">The object instance to copy.</param>
|
||||||
|
/// <returns>The copied object.</returns>
|
||||||
|
public static T CloneJson<T>(this T source)
|
||||||
|
{
|
||||||
|
// Don't serialize a null object, simply return the default for that object
|
||||||
|
return ReferenceEquals(source, null) ? default(T) : JsonConvert.DeserializeObject<T>(JsonConvert.SerializeObject(source), Settings);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
36
RequestPlex.Helpers/Properties/AssemblyInfo.cs
Normal file
36
RequestPlex.Helpers/Properties/AssemblyInfo.cs
Normal file
|
@ -0,0 +1,36 @@
|
||||||
|
using System.Reflection;
|
||||||
|
using System.Runtime.CompilerServices;
|
||||||
|
using System.Runtime.InteropServices;
|
||||||
|
|
||||||
|
// General Information about an assembly is controlled through the following
|
||||||
|
// set of attributes. Change these attribute values to modify the information
|
||||||
|
// associated with an assembly.
|
||||||
|
[assembly: AssemblyTitle("RequestPlex.Helpers")]
|
||||||
|
[assembly: AssemblyDescription("")]
|
||||||
|
[assembly: AssemblyConfiguration("")]
|
||||||
|
[assembly: AssemblyCompany("")]
|
||||||
|
[assembly: AssemblyProduct("RequestPlex.Helpers")]
|
||||||
|
[assembly: AssemblyCopyright("Copyright © 2016")]
|
||||||
|
[assembly: AssemblyTrademark("")]
|
||||||
|
[assembly: AssemblyCulture("")]
|
||||||
|
|
||||||
|
// Setting ComVisible to false makes the types in this assembly not visible
|
||||||
|
// to COM components. If you need to access a type in this assembly from
|
||||||
|
// COM, set the ComVisible attribute to true on that type.
|
||||||
|
[assembly: ComVisible(false)]
|
||||||
|
|
||||||
|
// The following GUID is for the ID of the typelib if this project is exposed to COM
|
||||||
|
[assembly: Guid("1252336d-42a3-482a-804c-836e60173dfa")]
|
||||||
|
|
||||||
|
// Version information for an assembly consists of the following four values:
|
||||||
|
//
|
||||||
|
// Major Version
|
||||||
|
// Minor Version
|
||||||
|
// Build Number
|
||||||
|
// Revision
|
||||||
|
//
|
||||||
|
// You can specify all the values or you can default the Build and Revision Numbers
|
||||||
|
// by using the '*' as shown below:
|
||||||
|
// [assembly: AssemblyVersion("1.0.*")]
|
||||||
|
[assembly: AssemblyVersion("1.0.0.0")]
|
||||||
|
[assembly: AssemblyFileVersion("1.0.0.0")]
|
66
RequestPlex.Helpers/RequestPlex.Helpers.csproj
Normal file
66
RequestPlex.Helpers/RequestPlex.Helpers.csproj
Normal file
|
@ -0,0 +1,66 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
|
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
||||||
|
<PropertyGroup>
|
||||||
|
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||||
|
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||||
|
<ProjectGuid>{1252336D-42A3-482A-804C-836E60173DFA}</ProjectGuid>
|
||||||
|
<OutputType>Library</OutputType>
|
||||||
|
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||||
|
<RootNamespace>RequestPlex.Helpers</RootNamespace>
|
||||||
|
<AssemblyName>RequestPlex.Helpers</AssemblyName>
|
||||||
|
<TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
|
||||||
|
<FileAlignment>512</FileAlignment>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||||
|
<DebugSymbols>true</DebugSymbols>
|
||||||
|
<DebugType>full</DebugType>
|
||||||
|
<Optimize>false</Optimize>
|
||||||
|
<OutputPath>bin\Debug\</OutputPath>
|
||||||
|
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||||
|
<ErrorReport>prompt</ErrorReport>
|
||||||
|
<WarningLevel>4</WarningLevel>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||||
|
<DebugType>pdbonly</DebugType>
|
||||||
|
<Optimize>true</Optimize>
|
||||||
|
<OutputPath>bin\Release\</OutputPath>
|
||||||
|
<DefineConstants>TRACE</DefineConstants>
|
||||||
|
<ErrorReport>prompt</ErrorReport>
|
||||||
|
<WarningLevel>4</WarningLevel>
|
||||||
|
</PropertyGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<Reference Include="Newtonsoft.Json, Version=8.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
|
||||||
|
<HintPath>..\packages\Newtonsoft.Json.8.0.2\lib\net45\Newtonsoft.Json.dll</HintPath>
|
||||||
|
<Private>True</Private>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="System" />
|
||||||
|
<Reference Include="System.Core" />
|
||||||
|
<Reference Include="System.Runtime.Caching" />
|
||||||
|
<Reference Include="System.Xml.Linq" />
|
||||||
|
<Reference Include="System.Data.DataSetExtensions" />
|
||||||
|
<Reference Include="Microsoft.CSharp" />
|
||||||
|
<Reference Include="System.Data" />
|
||||||
|
<Reference Include="System.Net.Http" />
|
||||||
|
<Reference Include="System.Xml" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<Compile Include="ICacheProvider.cs" />
|
||||||
|
<Compile Include="MemoryCacheProvider.cs" />
|
||||||
|
<Compile Include="ObjectCopier.cs" />
|
||||||
|
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||||
|
<Compile Include="SerializerSettings.cs" />
|
||||||
|
<Compile Include="StringCipher.cs" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<None Include="packages.config" />
|
||||||
|
</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.
|
||||||
|
<Target Name="BeforeBuild">
|
||||||
|
</Target>
|
||||||
|
<Target Name="AfterBuild">
|
||||||
|
</Target>
|
||||||
|
-->
|
||||||
|
</Project>
|
45
RequestPlex.Helpers/SerializerSettings.cs
Normal file
45
RequestPlex.Helpers/SerializerSettings.cs
Normal file
|
@ -0,0 +1,45 @@
|
||||||
|
#region Copyright
|
||||||
|
// /************************************************************************
|
||||||
|
// Copyright (c) 2016 Jamie Rees
|
||||||
|
// File: SerializerSettings.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.Runtime.Serialization.Formatters;
|
||||||
|
|
||||||
|
using Newtonsoft.Json;
|
||||||
|
|
||||||
|
namespace RequestPlex.Helpers
|
||||||
|
{
|
||||||
|
public static class SerializerSettings
|
||||||
|
{
|
||||||
|
|
||||||
|
public static readonly JsonSerializerSettings Settings = new JsonSerializerSettings
|
||||||
|
{
|
||||||
|
Formatting = Formatting.None,
|
||||||
|
TypeNameHandling = TypeNameHandling.Objects,
|
||||||
|
TypeNameAssemblyFormat = FormatterAssemblyStyle.Simple,
|
||||||
|
NullValueHandling = NullValueHandling.Ignore
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
145
RequestPlex.Helpers/StringCipher.cs
Normal file
145
RequestPlex.Helpers/StringCipher.cs
Normal file
|
@ -0,0 +1,145 @@
|
||||||
|
#region Copyright
|
||||||
|
// /************************************************************************
|
||||||
|
// Copyright (c) 2016 Jamie Rees
|
||||||
|
// File: StringCipher.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;
|
||||||
|
using System.IO;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Security.Cryptography;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace RequestPlex.Helpers
|
||||||
|
{
|
||||||
|
public class StringCipher
|
||||||
|
{
|
||||||
|
// This constant determines the number of iterations for the password bytes generation function.
|
||||||
|
private const int DerivationIterations = 1000;
|
||||||
|
// This constant is used to determine the keysize of the encryption algorithm in bits.
|
||||||
|
// We divide this by 8 within the code below to get the equivalent number of bytes.
|
||||||
|
private const int Keysize = 256;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Decrypts the specified cipher text.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="cipherText">The cipher text.</param>
|
||||||
|
/// <param name="passPhrase">The pass phrase.</param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static string Decrypt(string cipherText, string passPhrase)
|
||||||
|
{
|
||||||
|
// Get the complete stream of bytes that represent:
|
||||||
|
// [32 bytes of Salt] + [32 bytes of IV] + [n bytes of CipherText]
|
||||||
|
var cipherTextBytesWithSaltAndIv = Convert.FromBase64String(cipherText);
|
||||||
|
// Get the saltbytes by extracting the first 32 bytes from the supplied cipherText bytes.
|
||||||
|
var saltStringBytes = cipherTextBytesWithSaltAndIv.Take(Keysize / 8).ToArray();
|
||||||
|
// Get the IV bytes by extracting the next 32 bytes from the supplied cipherText bytes.
|
||||||
|
var ivStringBytes = cipherTextBytesWithSaltAndIv.Skip(Keysize / 8).Take(Keysize / 8).ToArray();
|
||||||
|
// Get the actual cipher text bytes by removing the first 64 bytes from the cipherText string.
|
||||||
|
var cipherTextBytes = cipherTextBytesWithSaltAndIv.Skip((Keysize / 8) * 2).Take(cipherTextBytesWithSaltAndIv.Length - ((Keysize / 8) * 2)).ToArray();
|
||||||
|
|
||||||
|
using (var password = new Rfc2898DeriveBytes(passPhrase, saltStringBytes, DerivationIterations))
|
||||||
|
{
|
||||||
|
var keyBytes = password.GetBytes(Keysize / 8);
|
||||||
|
using (var symmetricKey = new RijndaelManaged())
|
||||||
|
{
|
||||||
|
symmetricKey.BlockSize = 256;
|
||||||
|
symmetricKey.Mode = CipherMode.CBC;
|
||||||
|
symmetricKey.Padding = PaddingMode.PKCS7;
|
||||||
|
using (var decryptor = symmetricKey.CreateDecryptor(keyBytes, ivStringBytes))
|
||||||
|
{
|
||||||
|
using (var memoryStream = new MemoryStream(cipherTextBytes))
|
||||||
|
{
|
||||||
|
using (var cryptoStream = new CryptoStream(memoryStream, decryptor, CryptoStreamMode.Read))
|
||||||
|
{
|
||||||
|
var plainTextBytes = new byte[cipherTextBytes.Length];
|
||||||
|
var decryptedByteCount = cryptoStream.Read(plainTextBytes, 0, plainTextBytes.Length);
|
||||||
|
memoryStream.Close();
|
||||||
|
cryptoStream.Close();
|
||||||
|
return Encoding.UTF8.GetString(plainTextBytes, 0, decryptedByteCount);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Encrypts the specified plain text.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="plainText">The plain text.</param>
|
||||||
|
/// <param name="passPhrase">The pass phrase.</param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static string Encrypt(string plainText, string passPhrase)
|
||||||
|
{
|
||||||
|
// Salt and IV is randomly generated each time, but is preprended to encrypted cipher text
|
||||||
|
// so that the same Salt and IV values can be used when decrypting.
|
||||||
|
var saltStringBytes = Generate256BitsOfRandomEntropy();
|
||||||
|
var ivStringBytes = Generate256BitsOfRandomEntropy();
|
||||||
|
var plainTextBytes = Encoding.UTF8.GetBytes(plainText);
|
||||||
|
using (var password = new Rfc2898DeriveBytes(passPhrase, saltStringBytes, DerivationIterations))
|
||||||
|
{
|
||||||
|
var keyBytes = password.GetBytes(Keysize / 8);
|
||||||
|
using (var symmetricKey = new RijndaelManaged())
|
||||||
|
{
|
||||||
|
symmetricKey.BlockSize = 256;
|
||||||
|
symmetricKey.Mode = CipherMode.CBC;
|
||||||
|
symmetricKey.Padding = PaddingMode.PKCS7;
|
||||||
|
using (var encryptor = symmetricKey.CreateEncryptor(keyBytes, ivStringBytes))
|
||||||
|
{
|
||||||
|
using (var memoryStream = new MemoryStream())
|
||||||
|
{
|
||||||
|
using (var cryptoStream = new CryptoStream(memoryStream, encryptor, CryptoStreamMode.Write))
|
||||||
|
{
|
||||||
|
cryptoStream.Write(plainTextBytes, 0, plainTextBytes.Length);
|
||||||
|
cryptoStream.FlushFinalBlock();
|
||||||
|
// Create the final bytes as a concatenation of the random salt bytes, the random iv bytes and the cipher bytes.
|
||||||
|
var cipherTextBytes = saltStringBytes;
|
||||||
|
cipherTextBytes = cipherTextBytes.Concat(ivStringBytes).ToArray();
|
||||||
|
cipherTextBytes = cipherTextBytes.Concat(memoryStream.ToArray()).ToArray();
|
||||||
|
memoryStream.Close();
|
||||||
|
cryptoStream.Close();
|
||||||
|
return Convert.ToBase64String(cipherTextBytes);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Generate256s the bits of random entropy.
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
private static byte[] Generate256BitsOfRandomEntropy()
|
||||||
|
{
|
||||||
|
var randomBytes = new byte[32]; // 32 Bytes will give us 256 bits.
|
||||||
|
using (var rngCsp = new RNGCryptoServiceProvider())
|
||||||
|
{
|
||||||
|
// Fill the array with cryptographically secure random bytes.
|
||||||
|
rngCsp.GetBytes(randomBytes);
|
||||||
|
}
|
||||||
|
return randomBytes;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
4
RequestPlex.Helpers/packages.config
Normal file
4
RequestPlex.Helpers/packages.config
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<packages>
|
||||||
|
<package id="Newtonsoft.Json" version="8.0.2" targetFramework="net452" />
|
||||||
|
</packages>
|
|
@ -1,9 +1,29 @@
|
||||||
using System;
|
#region Copyright
|
||||||
using System.Collections.Generic;
|
// /************************************************************************
|
||||||
using System.Linq;
|
// Copyright (c) 2016 Jamie Rees
|
||||||
using System.Text;
|
// File: Entity.cs
|
||||||
using System.Threading.Tasks;
|
// 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 Dapper.Contrib.Extensions;
|
using Dapper.Contrib.Extensions;
|
||||||
|
|
||||||
namespace RequestPlex.Store
|
namespace RequestPlex.Store
|
||||||
|
|
|
@ -1,8 +1,31 @@
|
||||||
using System;
|
#region Copyright
|
||||||
|
// /************************************************************************
|
||||||
|
// Copyright (c) 2016 Jamie Rees
|
||||||
|
// File: GenericRepository.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;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
using Dapper.Contrib.Extensions;
|
using Dapper.Contrib.Extensions;
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,30 @@
|
||||||
using System;
|
#region Copyright
|
||||||
|
// /************************************************************************
|
||||||
|
// Copyright (c) 2016 Jamie Rees
|
||||||
|
// File: IRepository.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.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace RequestPlex.Store
|
namespace RequestPlex.Store
|
||||||
{
|
{
|
||||||
|
|
70
RequestPlex.Store/ISettingsRepository.cs
Normal file
70
RequestPlex.Store/ISettingsRepository.cs
Normal file
|
@ -0,0 +1,70 @@
|
||||||
|
#region Copyright
|
||||||
|
// /************************************************************************
|
||||||
|
// Copyright (c) 2016 Jamie Rees
|
||||||
|
// File: ISettingsRepository.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.Collections.Generic;
|
||||||
|
|
||||||
|
using RequestPlex.Store.Models;
|
||||||
|
|
||||||
|
namespace RequestPlex.Store
|
||||||
|
{
|
||||||
|
public interface ISettingsRepository
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Inserts the specified entity.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="entity">The entity.</param>
|
||||||
|
long Insert(GlobalSettings entity);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets all.
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
IEnumerable<GlobalSettings> GetAll();
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the specified identifier.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="settingsName">Name of the settings.</param>
|
||||||
|
/// <returns></returns>
|
||||||
|
GlobalSettings Get(string settingsName);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Deletes the specified entity.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="entity">The entity.</param>
|
||||||
|
/// <returns></returns>
|
||||||
|
bool Delete(GlobalSettings entity);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Updates the specified entity.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="entity">The entity.</param>
|
||||||
|
/// <returns></returns>
|
||||||
|
bool Update(GlobalSettings entity);
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
39
RequestPlex.Store/Models/GlobalSettings.cs
Normal file
39
RequestPlex.Store/Models/GlobalSettings.cs
Normal file
|
@ -0,0 +1,39 @@
|
||||||
|
#region Copyright
|
||||||
|
// /************************************************************************
|
||||||
|
// Copyright (c) 2016 Jamie Rees
|
||||||
|
// File: GlobalSettings.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 Dapper.Contrib.Extensions;
|
||||||
|
|
||||||
|
namespace RequestPlex.Store.Models
|
||||||
|
{
|
||||||
|
|
||||||
|
[Table("GlobalSettings")]
|
||||||
|
public class GlobalSettings : Entity
|
||||||
|
{
|
||||||
|
public string Content { get; set; }
|
||||||
|
public string SettingsName { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
119
RequestPlex.Store/Repository/JsonRepository.cs
Normal file
119
RequestPlex.Store/Repository/JsonRepository.cs
Normal file
|
@ -0,0 +1,119 @@
|
||||||
|
#region Copyright
|
||||||
|
// /************************************************************************
|
||||||
|
// Copyright (c) 2016 Jamie Rees
|
||||||
|
// File: JsonRepository.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.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
|
||||||
|
using Dapper.Contrib.Extensions;
|
||||||
|
|
||||||
|
using RequestPlex.Helpers;
|
||||||
|
using RequestPlex.Store.Models;
|
||||||
|
|
||||||
|
namespace RequestPlex.Store.Repository
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
|
namespace NZBDash.DataAccessLayer.Repository
|
||||||
|
{
|
||||||
|
public class JsonRepository : ISettingsRepository
|
||||||
|
{
|
||||||
|
private ICacheProvider Cache { get; set; }
|
||||||
|
|
||||||
|
private string TypeName { get; set; }
|
||||||
|
public JsonRepository(ISqliteConfiguration config, ICacheProvider cacheProvider)
|
||||||
|
{
|
||||||
|
Db = config;
|
||||||
|
Cache = cacheProvider;
|
||||||
|
TypeName = typeof(JsonRepository).Name;
|
||||||
|
}
|
||||||
|
|
||||||
|
private ISqliteConfiguration Db { get; set; }
|
||||||
|
|
||||||
|
public long Insert(GlobalSettings entity)
|
||||||
|
{
|
||||||
|
ResetCache();
|
||||||
|
using (var con = Db.DbConnection())
|
||||||
|
{
|
||||||
|
return con.Insert(entity);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public IEnumerable<GlobalSettings> GetAll()
|
||||||
|
{
|
||||||
|
var key = TypeName + "GetAll";
|
||||||
|
var item = Cache.GetOrSet(key, () =>
|
||||||
|
{
|
||||||
|
using (var con = Db.DbConnection())
|
||||||
|
{
|
||||||
|
var page = con.GetAll<GlobalSettings>();
|
||||||
|
return page;
|
||||||
|
}
|
||||||
|
}, 5);
|
||||||
|
return item;
|
||||||
|
}
|
||||||
|
|
||||||
|
public GlobalSettings Get(string pageName)
|
||||||
|
{
|
||||||
|
var key = pageName + "Get";
|
||||||
|
var item = Cache.GetOrSet(key, () =>
|
||||||
|
{
|
||||||
|
using (var con = Db.DbConnection())
|
||||||
|
{
|
||||||
|
var page = con.GetAll<GlobalSettings>().SingleOrDefault(x => x.SettingsName == pageName);
|
||||||
|
return page;
|
||||||
|
}
|
||||||
|
}, 5);
|
||||||
|
return item;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool Delete(GlobalSettings entity)
|
||||||
|
{
|
||||||
|
ResetCache();
|
||||||
|
using (var con = Db.DbConnection())
|
||||||
|
{
|
||||||
|
return con.Delete(entity);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool Update(GlobalSettings entity)
|
||||||
|
{
|
||||||
|
ResetCache();
|
||||||
|
using (var con = Db.DbConnection())
|
||||||
|
{
|
||||||
|
return con.Update(entity);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ResetCache()
|
||||||
|
{
|
||||||
|
Cache.Remove("Get");
|
||||||
|
Cache.Remove(TypeName + "GetAll");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -53,9 +53,12 @@
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Compile Include="DbConfiguration.cs" />
|
<Compile Include="DbConfiguration.cs" />
|
||||||
<Compile Include="Entity.cs" />
|
<Compile Include="Entity.cs" />
|
||||||
|
<Compile Include="ISettingsRepository.cs" />
|
||||||
<Compile Include="ISqliteConfiguration.cs" />
|
<Compile Include="ISqliteConfiguration.cs" />
|
||||||
<Compile Include="IRepository.cs" />
|
<Compile Include="IRepository.cs" />
|
||||||
|
<Compile Include="Models\GlobalSettings.cs" />
|
||||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||||
|
<Compile Include="Repository\JsonRepository.cs" />
|
||||||
<Compile Include="SettingsModel.cs" />
|
<Compile Include="SettingsModel.cs" />
|
||||||
<Compile Include="GenericRepository.cs" />
|
<Compile Include="GenericRepository.cs" />
|
||||||
<Compile Include="RequestedModel.cs" />
|
<Compile Include="RequestedModel.cs" />
|
||||||
|
@ -83,6 +86,12 @@
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<None Include="packages.config" />
|
<None Include="packages.config" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<ProjectReference Include="..\RequestPlex.Helpers\RequestPlex.Helpers.csproj">
|
||||||
|
<Project>{1252336D-42A3-482A-804C-836E60173DFA}</Project>
|
||||||
|
<Name>RequestPlex.Helpers</Name>
|
||||||
|
</ProjectReference>
|
||||||
|
</ItemGroup>
|
||||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
<!-- 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.
|
Other similar extension points exist, see Microsoft.Common.targets.
|
||||||
|
|
|
@ -1,4 +1,6 @@
|
||||||
using Dapper.Contrib.Extensions;
|
using System;
|
||||||
|
|
||||||
|
using Dapper.Contrib.Extensions;
|
||||||
|
|
||||||
namespace RequestPlex.Store
|
namespace RequestPlex.Store
|
||||||
{
|
{
|
||||||
|
@ -7,7 +9,13 @@ namespace RequestPlex.Store
|
||||||
{
|
{
|
||||||
// ReSharper disable once IdentifierTypo
|
// ReSharper disable once IdentifierTypo
|
||||||
public int Tmdbid { get; set; }
|
public int Tmdbid { get; set; }
|
||||||
|
public string ImdbId { get; set; }
|
||||||
|
public string Overview { get; set; }
|
||||||
|
public string Title { get; set; }
|
||||||
|
public string PosterPath { get; set; }
|
||||||
|
public DateTime ReleaseDate { get; set; }
|
||||||
public RequestType Type { get; set; }
|
public RequestType Type { get; set; }
|
||||||
|
public string Status { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public enum RequestType
|
public enum RequestType
|
||||||
|
|
|
@ -20,5 +20,18 @@ CREATE TABLE IF NOT EXISTS Requested
|
||||||
(
|
(
|
||||||
Id INTEGER PRIMARY KEY AUTOINCREMENT,
|
Id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||||
Type INTEGER NOT NULL,
|
Type INTEGER NOT NULL,
|
||||||
Tmdbid INTEGER NOT NULL
|
Tmdbid INTEGER NOT NULL,
|
||||||
|
ImdbId varchar(50) NOT NULL,
|
||||||
|
Overview varchar(50) NOT NULL,
|
||||||
|
Title varchar(50) NOT NULL,
|
||||||
|
PosterPath varchar(50) NOT NULL,
|
||||||
|
ReleaseDate varchar(50) NOT NULL,
|
||||||
|
Status varchar(50) NOT NULL
|
||||||
|
);
|
||||||
|
|
||||||
|
CREATE TABLE IF NOT EXISTS GlobalSettings
|
||||||
|
(
|
||||||
|
Id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||||
|
SettingsName varchar(50) NOT NULL,
|
||||||
|
Content varchar(100) NOT NULL
|
||||||
);
|
);
|
|
@ -1,8 +1,32 @@
|
||||||
using System;
|
#region Copyright
|
||||||
|
// /************************************************************************
|
||||||
|
// Copyright (c) 2016 Jamie Rees
|
||||||
|
// File: UserRepository.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;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
using Dapper.Contrib.Extensions;
|
using Dapper.Contrib.Extensions;
|
||||||
|
|
||||||
|
|
|
@ -1,9 +1,16 @@
|
||||||
using Nancy;
|
using Mono.Data.Sqlite;
|
||||||
|
|
||||||
|
using Nancy;
|
||||||
using Nancy.Authentication.Forms;
|
using Nancy.Authentication.Forms;
|
||||||
using Nancy.Bootstrapper;
|
using Nancy.Bootstrapper;
|
||||||
using Nancy.TinyIoc;
|
using Nancy.TinyIoc;
|
||||||
|
|
||||||
using RequestPlex.Core;
|
using RequestPlex.Core;
|
||||||
|
using RequestPlex.Core.SettingModels;
|
||||||
|
using RequestPlex.Helpers;
|
||||||
|
using RequestPlex.Store;
|
||||||
|
using RequestPlex.Store.Models;
|
||||||
|
using RequestPlex.Store.Repository.NZBDash.DataAccessLayer.Repository;
|
||||||
|
|
||||||
using FormsAuthentication = Nancy.Authentication.Forms.FormsAuthentication;
|
using FormsAuthentication = Nancy.Authentication.Forms.FormsAuthentication;
|
||||||
|
|
||||||
|
@ -17,8 +24,22 @@ namespace RequestPlex.UI
|
||||||
|
|
||||||
protected override void ConfigureRequestContainer(TinyIoCContainer container, NancyContext context)
|
protected override void ConfigureRequestContainer(TinyIoCContainer container, NancyContext context)
|
||||||
{
|
{
|
||||||
base.ConfigureRequestContainer(container, context);
|
|
||||||
container.Register<IUserMapper, UserMapper>();
|
container.Register<IUserMapper, UserMapper>();
|
||||||
|
base.ConfigureRequestContainer(container, context);
|
||||||
|
|
||||||
|
container.Register<ISqliteConfiguration, DbConfiguration>(new DbConfiguration(new SqliteFactory()));
|
||||||
|
|
||||||
|
container.Register<ISettingsRepository, JsonRepository>();
|
||||||
|
container.Register<ICacheProvider, MemoryCacheProvider>();
|
||||||
|
|
||||||
|
|
||||||
|
container.Register<ISettingsService<RequestPlexSettings>, SettingsServiceV2<RequestPlexSettings>>();
|
||||||
|
container.Register<IRepository<RequestedModel>, GenericRepository<RequestedModel>>();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void ApplicationStartup(TinyIoCContainer container, IPipelines pipelines)
|
protected override void ApplicationStartup(TinyIoCContainer container, IPipelines pipelines)
|
||||||
|
|
71
RequestPlex.UI/Content/requests.js
Normal file
71
RequestPlex.UI/Content/requests.js
Normal file
|
@ -0,0 +1,71 @@
|
||||||
|
Handlebars.registerHelper('if_eq', function (a, b, opts) {
|
||||||
|
if (a == b)
|
||||||
|
return opts.fn(this);
|
||||||
|
else
|
||||||
|
return opts.inverse(this);
|
||||||
|
});
|
||||||
|
|
||||||
|
var searchSource = $("#search-template").html();
|
||||||
|
var searchTemplate = Handlebars.compile(searchSource);
|
||||||
|
var movieTimer = 0;
|
||||||
|
var tvimer = 0;
|
||||||
|
|
||||||
|
movieLoad();
|
||||||
|
tvLoad();
|
||||||
|
|
||||||
|
|
||||||
|
function movieLoad() {
|
||||||
|
$("#movieList").html("");
|
||||||
|
|
||||||
|
$.ajax("/requests/movies/").success(function (results) {
|
||||||
|
results.forEach(function (result) {
|
||||||
|
var context = buildMovieRequestContext(result);
|
||||||
|
|
||||||
|
var html = searchTemplate(context);
|
||||||
|
$("#movieList").append(html);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
function tvLoad() {
|
||||||
|
$("#tvList").html("");
|
||||||
|
|
||||||
|
$.ajax("/requests/tvshows/").success(function (results) {
|
||||||
|
results.forEach(function (result) {
|
||||||
|
var context = buildTvShowRequestContext(result);
|
||||||
|
var html = searchTemplate(context);
|
||||||
|
$("#tvList").append(html);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
function buildMovieRequestContext(result) {
|
||||||
|
var date = new Date(result.releaseDate);
|
||||||
|
var year = date.getFullYear();
|
||||||
|
var context = {
|
||||||
|
posterPath: result.posterPath,
|
||||||
|
id: result.tmdbid,
|
||||||
|
title: result.title,
|
||||||
|
overview: result.overview,
|
||||||
|
year: year,
|
||||||
|
type: "movie",
|
||||||
|
status: result.status
|
||||||
|
};
|
||||||
|
|
||||||
|
return context;
|
||||||
|
}
|
||||||
|
|
||||||
|
function buildTvShowRequestContext(result) {
|
||||||
|
var date = new Date(result.releaseDate);
|
||||||
|
var year = date.getFullYear();
|
||||||
|
var context = {
|
||||||
|
posterPath: result.posterPath,
|
||||||
|
id: result.tmdbid,
|
||||||
|
title: result.name,
|
||||||
|
overview: result.overview,
|
||||||
|
year: year,
|
||||||
|
type: "tv",
|
||||||
|
status: result.status
|
||||||
|
};
|
||||||
|
return context;
|
||||||
|
}
|
|
@ -1,26 +1,66 @@
|
||||||
var searchSource = $("#search-template").html();
|
Handlebars.registerHelper('if_eq', function (a, b, opts) {
|
||||||
|
if (a == b)
|
||||||
|
return opts.fn(this);
|
||||||
|
else
|
||||||
|
return opts.inverse(this);
|
||||||
|
});
|
||||||
|
|
||||||
|
var searchSource = $("#search-template").html();
|
||||||
var searchTemplate = Handlebars.compile(searchSource);
|
var searchTemplate = Handlebars.compile(searchSource);
|
||||||
var movieTimer = 0;
|
var movieTimer = 0;
|
||||||
var tvimer = 0;
|
var tvimer = 0;
|
||||||
|
|
||||||
$("#movieSearchContent").on("keyup", function (e) {
|
$("#movieSearchContent").keypress(function (e) {
|
||||||
if (movieTimer) {
|
if (movieTimer) {
|
||||||
clearTimeout(movieTimer);
|
clearTimeout(movieTimer);
|
||||||
}
|
}
|
||||||
movieTimer = setTimeout(movieSearch, 400);
|
movieTimer = setTimeout(movieSearch, 400);
|
||||||
});
|
});
|
||||||
|
|
||||||
$("#tvSearchContent").on("keyup", function (e) {
|
$("#tvSearchContent").keypress(function (e) {
|
||||||
if (tvimer) {
|
if (tvimer) {
|
||||||
clearTimeout(tvimer);
|
clearTimeout(tvimer);
|
||||||
}
|
}
|
||||||
tvimer = setTimeout(tvSearch(), 400);
|
tvimer = setTimeout(tvSearch(), 400);
|
||||||
});
|
});
|
||||||
|
|
||||||
$("#test").click(function (e) {
|
$(document).on("click", ".dropdownTv", function (e) {
|
||||||
|
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
|
console.log(e.target.id);
|
||||||
var $form = $('#form'+e.target.id);
|
var $form = $('#form'+e.target.id);
|
||||||
|
var data = $form.serialize();
|
||||||
|
var seasons = $(this).attr("season-select");
|
||||||
|
console.log(data);
|
||||||
|
if (seasons === "1") {
|
||||||
|
data = data + "&latest=true";
|
||||||
|
}
|
||||||
|
|
||||||
|
$.ajax({
|
||||||
|
type: $form.prop('method'),
|
||||||
|
url: $form.prop('action'),
|
||||||
|
data: data,
|
||||||
|
dataType: "json",
|
||||||
|
success: function (response) {
|
||||||
|
console.log(response);
|
||||||
|
if (response.result === true) {
|
||||||
|
generateNotify("Success!", "success");
|
||||||
|
} else {
|
||||||
|
generateNotify(response.message, "warning");
|
||||||
|
}
|
||||||
|
},
|
||||||
|
error: function (e) {
|
||||||
|
console.log(e);
|
||||||
|
generateNotify("Something went wrong!", "danger");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
$(document).on("click", ".requestMovie", function (e) {
|
||||||
|
e.preventDefault();
|
||||||
|
console.log(e.target.id);
|
||||||
|
var $form = $('#form' + e.target.id);
|
||||||
|
|
||||||
$.ajax({
|
$.ajax({
|
||||||
type: $form.prop('method'),
|
type: $form.prop('method'),
|
||||||
|
@ -29,10 +69,10 @@ $("#test").click(function (e) {
|
||||||
dataType: "json",
|
dataType: "json",
|
||||||
success: function (response) {
|
success: function (response) {
|
||||||
console.log(response);
|
console.log(response);
|
||||||
if (response.Result === true) {
|
if (response.result === true) {
|
||||||
generateNotify("Success!", "success");
|
generateNotify("Success!", "success");
|
||||||
} else {
|
} else {
|
||||||
generateNotify(response.Message, "warning");
|
generateNotify(response.message, "warning");
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
error: function (e) {
|
error: function (e) {
|
||||||
|
@ -71,35 +111,3 @@ function tvSearch() {
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
function buildMovieContext(result) {
|
|
||||||
var date = new Date(result.releaseDate);
|
|
||||||
var year = date.getFullYear();
|
|
||||||
var context = {
|
|
||||||
posterPath: result.posterPath,
|
|
||||||
id: result.id,
|
|
||||||
title: result.title,
|
|
||||||
overview: result.overview,
|
|
||||||
voteCount: result.voteCount,
|
|
||||||
voteAverage: result.voteAverage,
|
|
||||||
year: year,
|
|
||||||
type : "movie"
|
|
||||||
};
|
|
||||||
|
|
||||||
return context;
|
|
||||||
}
|
|
||||||
|
|
||||||
function buildTvShowContext(result) {
|
|
||||||
var date = new Date(result.firstAirDate);
|
|
||||||
var year = date.getFullYear();
|
|
||||||
var context = {
|
|
||||||
posterPath: result.posterPath,
|
|
||||||
id: result.id,
|
|
||||||
title: result.name,
|
|
||||||
overview: result.overview,
|
|
||||||
voteCount: result.voteCount,
|
|
||||||
voteAverage: result.voteAverage,
|
|
||||||
year: year,
|
|
||||||
type: "tv"
|
|
||||||
};
|
|
||||||
return context;
|
|
||||||
}
|
|
||||||
|
|
|
@ -1,7 +1,4 @@
|
||||||
|
function generateNotify(message, type) {
|
||||||
|
|
||||||
|
|
||||||
function generateNotify(message, type) {
|
|
||||||
// type = danger, warning, info, successs
|
// type = danger, warning, info, successs
|
||||||
$.notify({
|
$.notify({
|
||||||
// options
|
// options
|
||||||
|
@ -10,4 +7,37 @@ function generateNotify(message, type) {
|
||||||
// settings
|
// settings
|
||||||
type: type
|
type: type
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function buildMovieContext(result) {
|
||||||
|
var date = new Date(result.releaseDate);
|
||||||
|
var year = date.getFullYear();
|
||||||
|
var context = {
|
||||||
|
posterPath: result.posterPath,
|
||||||
|
id: result.id,
|
||||||
|
title: result.title,
|
||||||
|
overview: result.overview,
|
||||||
|
voteCount: result.voteCount,
|
||||||
|
voteAverage: result.voteAverage,
|
||||||
|
year: year,
|
||||||
|
type: "movie"
|
||||||
|
};
|
||||||
|
|
||||||
|
return context;
|
||||||
|
}
|
||||||
|
|
||||||
|
function buildTvShowContext(result) {
|
||||||
|
var date = new Date(result.firstAirDate);
|
||||||
|
var year = date.getFullYear();
|
||||||
|
var context = {
|
||||||
|
posterPath: result.posterPath,
|
||||||
|
id: result.id,
|
||||||
|
title: result.name,
|
||||||
|
overview: result.overview,
|
||||||
|
voteCount: result.voteCount,
|
||||||
|
voteAverage: result.voteAverage,
|
||||||
|
year: year,
|
||||||
|
type: "tv"
|
||||||
|
};
|
||||||
|
return context;
|
||||||
|
}
|
||||||
|
|
|
@ -1,7 +1,29 @@
|
||||||
using System;
|
#region Copyright
|
||||||
using System.Collections;
|
// /************************************************************************
|
||||||
using System.Collections.Generic;
|
// Copyright (c) 2016 Jamie Rees
|
||||||
using System.ComponentModel;
|
// File: AdminModule.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.Dynamic;
|
using System.Dynamic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Web.UI;
|
using System.Web.UI;
|
||||||
|
@ -9,18 +31,20 @@ using Nancy;
|
||||||
using Nancy.Extensions;
|
using Nancy.Extensions;
|
||||||
using Nancy.ModelBinding;
|
using Nancy.ModelBinding;
|
||||||
using Nancy.Security;
|
using Nancy.Security;
|
||||||
using Newtonsoft.Json;
|
|
||||||
using RequestPlex.Api;
|
using RequestPlex.Api;
|
||||||
using RequestPlex.Core;
|
using RequestPlex.Core;
|
||||||
using RequestPlex.Store;
|
using RequestPlex.Core.SettingModels;
|
||||||
using RequestPlex.UI.Models;
|
using RequestPlex.UI.Models;
|
||||||
|
|
||||||
namespace RequestPlex.UI.Modules
|
namespace RequestPlex.UI.Modules
|
||||||
{
|
{
|
||||||
public class AdminModule : NancyModule
|
public class AdminModule : NancyModule
|
||||||
{
|
{
|
||||||
public AdminModule()
|
private ISettingsService<RequestPlexSettings> Service { get; set; }
|
||||||
|
public AdminModule(ISettingsService<RequestPlexSettings> service)
|
||||||
{
|
{
|
||||||
|
Service = service;
|
||||||
#if !DEBUG
|
#if !DEBUG
|
||||||
this.RequiresAuthentication();
|
this.RequiresAuthentication();
|
||||||
#endif
|
#endif
|
||||||
|
@ -41,8 +65,8 @@ namespace RequestPlex.UI.Modules
|
||||||
dynamic model = new ExpandoObject();
|
dynamic model = new ExpandoObject();
|
||||||
model.Errored = Request.Query.error.HasValue;
|
model.Errored = Request.Query.error.HasValue;
|
||||||
model.Port = null;
|
model.Port = null;
|
||||||
var s = new SettingsService();
|
|
||||||
var settings = s.GetSettings();
|
var settings = Service.GetSettings();
|
||||||
if (settings != null)
|
if (settings != null)
|
||||||
{
|
{
|
||||||
model.Port = settings.Port;
|
model.Port = settings.Port;
|
||||||
|
@ -54,10 +78,9 @@ namespace RequestPlex.UI.Modules
|
||||||
|
|
||||||
private Response SaveAdmin()
|
private Response SaveAdmin()
|
||||||
{
|
{
|
||||||
var model = this.Bind<SettingsModel>();
|
var model = this.Bind<RequestPlexSettings>();
|
||||||
|
|
||||||
var s = new SettingsService();
|
Service.SaveSettings(model);
|
||||||
s.SaveSettings(model);
|
|
||||||
|
|
||||||
|
|
||||||
return Context.GetRedirect("~/admin");
|
return Context.GetRedirect("~/admin");
|
||||||
|
@ -74,20 +97,19 @@ namespace RequestPlex.UI.Modules
|
||||||
|
|
||||||
var plex = new PlexApi();
|
var plex = new PlexApi();
|
||||||
var model = plex.GetToken(user.username, user.password);
|
var model = plex.GetToken(user.username, user.password);
|
||||||
var s = new SettingsService();
|
var oldSettings = Service.GetSettings();
|
||||||
var oldSettings = s.GetSettings();
|
|
||||||
if (oldSettings != null)
|
if (oldSettings != null)
|
||||||
{
|
{
|
||||||
oldSettings.PlexAuthToken = model.user.authentication_token;
|
oldSettings.PlexAuthToken = model.user.authentication_token;
|
||||||
s.SaveSettings(oldSettings);
|
Service.SaveSettings(oldSettings);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
var newModel = new SettingsModel
|
var newModel = new RequestPlexSettings
|
||||||
{
|
{
|
||||||
PlexAuthToken = model.user.authentication_token
|
PlexAuthToken = model.user.authentication_token
|
||||||
};
|
};
|
||||||
s.SaveSettings(newModel);
|
Service.SaveSettings(newModel);
|
||||||
}
|
}
|
||||||
|
|
||||||
return Context.GetRedirect("~/admin");
|
return Context.GetRedirect("~/admin");
|
||||||
|
@ -96,8 +118,7 @@ namespace RequestPlex.UI.Modules
|
||||||
|
|
||||||
private Response GetUsers()
|
private Response GetUsers()
|
||||||
{
|
{
|
||||||
var s = new SettingsService();
|
var token = Service.GetSettings().PlexAuthToken;
|
||||||
var token = s.GetSettings().PlexAuthToken;
|
|
||||||
var api = new PlexApi();
|
var api = new PlexApi();
|
||||||
var users = api.GetUsers(token);
|
var users = api.GetUsers(token);
|
||||||
var usernames = users.User.Select(x => x.Username);
|
var usernames = users.User.Select(x => x.Username);
|
||||||
|
|
|
@ -1,4 +1,6 @@
|
||||||
using Nancy;
|
using Nancy;
|
||||||
|
using Nancy.Extensions;
|
||||||
|
using Nancy.Responses;
|
||||||
|
|
||||||
namespace RequestPlex.UI.Modules
|
namespace RequestPlex.UI.Modules
|
||||||
{
|
{
|
||||||
|
@ -6,8 +8,8 @@ namespace RequestPlex.UI.Modules
|
||||||
{
|
{
|
||||||
public IndexModule()
|
public IndexModule()
|
||||||
{
|
{
|
||||||
Get["/"] = parameters => View["Index"];
|
Get["/"] = parameters => Context.GetRedirect("~/search");
|
||||||
Get["/Index"] = parameters => View["Index"];
|
Get["/Index"] = parameters => Context.GetRedirect("~/search");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,12 +1,43 @@
|
||||||
|
using System.Linq;
|
||||||
|
|
||||||
using Nancy;
|
using Nancy;
|
||||||
|
using Nancy.Responses.Negotiation;
|
||||||
|
|
||||||
|
using RequestPlex.Api;
|
||||||
|
using RequestPlex.Core;
|
||||||
|
using RequestPlex.Core.SettingModels;
|
||||||
|
using RequestPlex.Store;
|
||||||
|
|
||||||
namespace RequestPlex.UI.Modules
|
namespace RequestPlex.UI.Modules
|
||||||
{
|
{
|
||||||
public class RequestsModule : NancyModule
|
public class RequestsModule : NancyModule
|
||||||
{
|
{
|
||||||
public RequestsModule()
|
private IRepository<RequestedModel> Service { get; set; }
|
||||||
|
public RequestsModule(IRepository<RequestedModel> service)
|
||||||
{
|
{
|
||||||
Get["requests/"] = _ => "Hello!";
|
Service = service;
|
||||||
|
|
||||||
|
Get["requests/"] = _ => LoadRequests();
|
||||||
|
Get["requests/movies"] = _ => GetMovies();
|
||||||
|
Get["requests/tvshows"] = _ => GetTvShows();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private Negotiator LoadRequests()
|
||||||
|
{
|
||||||
|
return View["Requests/Index"];
|
||||||
|
}
|
||||||
|
|
||||||
|
private Response GetMovies()
|
||||||
|
{
|
||||||
|
var dbMovies = Service.GetAll().Where(x => x.Type == RequestType.Movie);
|
||||||
|
return Response.AsJson(dbMovies);
|
||||||
|
}
|
||||||
|
|
||||||
|
private Response GetTvShows()
|
||||||
|
{
|
||||||
|
var dbTv = Service.GetAll().Where(x => x.Type == RequestType.TvShow);
|
||||||
|
return Response.AsJson(dbTv);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -37,7 +37,7 @@ namespace RequestPlex.UI.Modules
|
||||||
Post["search/request/tv"] = parameters =>
|
Post["search/request/tv"] = parameters =>
|
||||||
{
|
{
|
||||||
var tvShowId = (int)Request.Form.tvId;
|
var tvShowId = (int)Request.Form.tvId;
|
||||||
var latest = (bool)Request.Form.latestSeason;
|
var latest = (bool)Request.Form.latest;
|
||||||
return RequestTvShow(tvShowId, latest);
|
return RequestTvShow(tvShowId, latest);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -49,7 +49,6 @@ namespace RequestPlex.UI.Modules
|
||||||
|
|
||||||
private Response SearchMovie(string searchTerm)
|
private Response SearchMovie(string searchTerm)
|
||||||
{
|
{
|
||||||
var s = new SettingsService();
|
|
||||||
var api = new TheMovieDbApi();
|
var api = new TheMovieDbApi();
|
||||||
var movies = api.SearchMovie(searchTerm);
|
var movies = api.SearchMovie(searchTerm);
|
||||||
var result = movies.Result;
|
var result = movies.Result;
|
||||||
|
@ -87,14 +86,25 @@ namespace RequestPlex.UI.Modules
|
||||||
{
|
{
|
||||||
return Response.AsJson(new { Result = false, Message = "Movie has already been requested!" });
|
return Response.AsJson(new { Result = false, Message = "Movie has already been requested!" });
|
||||||
}
|
}
|
||||||
|
|
||||||
s.AddRequest(movieId, RequestType.Movie);
|
s.AddRequest(movieId, RequestType.Movie);
|
||||||
return Response.AsJson(new { Result = true });
|
return Response.AsJson(new { Result = true });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Requests the tv show.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="showId">The show identifier.</param>
|
||||||
|
/// <param name="latest">if set to <c>true</c> [latest].</param>
|
||||||
|
/// <returns></returns>
|
||||||
private Response RequestTvShow(int showId, bool latest)
|
private Response RequestTvShow(int showId, bool latest)
|
||||||
{
|
{
|
||||||
// Latest send to Sonarr and no need to store in DB
|
// Latest send to Sonarr and no need to store in DB
|
||||||
var s = new SettingsService();
|
var s = new SettingsService();
|
||||||
|
if (s.CheckRequest(showId))
|
||||||
|
{
|
||||||
|
return Response.AsJson(new { Result = false, Message = "TV Show has already been requested!" });
|
||||||
|
}
|
||||||
s.AddRequest(showId, RequestType.TvShow);
|
s.AddRequest(showId, RequestType.TvShow);
|
||||||
return Response.AsJson(new {Result = true });
|
return Response.AsJson(new {Result = true });
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,9 +2,15 @@
|
||||||
|
|
||||||
using Microsoft.Owin.Hosting;
|
using Microsoft.Owin.Hosting;
|
||||||
|
|
||||||
|
using Mono.Data.Sqlite;
|
||||||
|
|
||||||
using Nancy.Hosting.Self;
|
using Nancy.Hosting.Self;
|
||||||
|
|
||||||
using RequestPlex.Core;
|
using RequestPlex.Core;
|
||||||
|
using RequestPlex.Core.SettingModels;
|
||||||
|
using RequestPlex.Helpers;
|
||||||
|
using RequestPlex.Store;
|
||||||
|
using RequestPlex.Store.Repository.NZBDash.DataAccessLayer.Repository;
|
||||||
|
|
||||||
namespace RequestPlex.UI
|
namespace RequestPlex.UI
|
||||||
{
|
{
|
||||||
|
@ -16,10 +22,10 @@ namespace RequestPlex.UI
|
||||||
var s = new Setup();
|
var s = new Setup();
|
||||||
s.SetupDb();
|
s.SetupDb();
|
||||||
|
|
||||||
var service = new SettingsService();
|
var service = new SettingsServiceV2<RequestPlexSettings>(new JsonRepository(new DbConfiguration(new SqliteFactory()), new MemoryCacheProvider()));
|
||||||
var settings = service.GetSettings();
|
var settings = service.GetSettings();
|
||||||
|
|
||||||
if (settings != null)
|
if (settings.Port != 0)
|
||||||
{
|
{
|
||||||
uri = $"http://localhost:{settings.Port}";
|
uri = $"http://localhost:{settings.Port}";
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,7 +10,7 @@ using System.Runtime.InteropServices;
|
||||||
[assembly: AssemblyConfiguration("")]
|
[assembly: AssemblyConfiguration("")]
|
||||||
[assembly: AssemblyCompany("")]
|
[assembly: AssemblyCompany("")]
|
||||||
[assembly: AssemblyProduct("RequestPlex.UI")]
|
[assembly: AssemblyProduct("RequestPlex.UI")]
|
||||||
[assembly: AssemblyCopyright("Copyright © 2013")]
|
[assembly: AssemblyCopyright("Copyright © 2016")]
|
||||||
[assembly: AssemblyTrademark("")]
|
[assembly: AssemblyTrademark("")]
|
||||||
[assembly: AssemblyCulture("")]
|
[assembly: AssemblyCulture("")]
|
||||||
|
|
||||||
|
@ -31,5 +31,5 @@ using System.Runtime.InteropServices;
|
||||||
//
|
//
|
||||||
// You can specify all the values or you can default the Revision and Build Numbers
|
// You can specify all the values or you can default the Revision and Build Numbers
|
||||||
// by using the '*' as shown below:
|
// by using the '*' as shown below:
|
||||||
[assembly: AssemblyVersion("1.0.0.0")]
|
[assembly: AssemblyVersion("1.0.*")]
|
||||||
[assembly: AssemblyFileVersion("1.0.0.0")]
|
[assembly: AssemblyFileVersion("1.0.0.0")]
|
||||||
|
|
|
@ -8,11 +8,26 @@
|
||||||
<OutputType>Exe</OutputType>
|
<OutputType>Exe</OutputType>
|
||||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||||
<RootNamespace>RequestPlex.UI</RootNamespace>
|
<RootNamespace>RequestPlex.UI</RootNamespace>
|
||||||
<AssemblyName>RequestPlex.UI</AssemblyName>
|
<AssemblyName>RequestPlex</AssemblyName>
|
||||||
<TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
|
<TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
|
||||||
<FileAlignment>512</FileAlignment>
|
<FileAlignment>512</FileAlignment>
|
||||||
<SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
|
<SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
|
||||||
<RestorePackages>true</RestorePackages>
|
<RestorePackages>true</RestorePackages>
|
||||||
|
<PublishUrl>publish\</PublishUrl>
|
||||||
|
<Install>true</Install>
|
||||||
|
<InstallFrom>Disk</InstallFrom>
|
||||||
|
<UpdateEnabled>false</UpdateEnabled>
|
||||||
|
<UpdateMode>Foreground</UpdateMode>
|
||||||
|
<UpdateInterval>7</UpdateInterval>
|
||||||
|
<UpdateIntervalUnits>Days</UpdateIntervalUnits>
|
||||||
|
<UpdatePeriodically>false</UpdatePeriodically>
|
||||||
|
<UpdateRequired>false</UpdateRequired>
|
||||||
|
<MapFileExtensions>true</MapFileExtensions>
|
||||||
|
<ApplicationRevision>0</ApplicationRevision>
|
||||||
|
<ApplicationVersion>1.0.0.%2a</ApplicationVersion>
|
||||||
|
<IsWebBootstrapper>false</IsWebBootstrapper>
|
||||||
|
<UseApplicationTrust>false</UseApplicationTrust>
|
||||||
|
<BootstrapperEnabled>true</BootstrapperEnabled>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||||
|
@ -23,6 +38,7 @@
|
||||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||||
<ErrorReport>prompt</ErrorReport>
|
<ErrorReport>prompt</ErrorReport>
|
||||||
<WarningLevel>4</WarningLevel>
|
<WarningLevel>4</WarningLevel>
|
||||||
|
<Prefer32Bit>false</Prefer32Bit>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||||
|
@ -50,6 +66,10 @@
|
||||||
<HintPath>..\packages\Microsoft.Owin.Hosting.3.0.1\lib\net45\Microsoft.Owin.Hosting.dll</HintPath>
|
<HintPath>..\packages\Microsoft.Owin.Hosting.3.0.1\lib\net45\Microsoft.Owin.Hosting.dll</HintPath>
|
||||||
<Private>True</Private>
|
<Private>True</Private>
|
||||||
</Reference>
|
</Reference>
|
||||||
|
<Reference Include="Mono.Data.Sqlite, Version=4.0.0.0, Culture=neutral, PublicKeyToken=0738eb9f132ed756, processorArchitecture=MSIL">
|
||||||
|
<SpecificVersion>False</SpecificVersion>
|
||||||
|
<HintPath>..\Assemblies\Mono.Data.Sqlite.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
<Reference Include="Nancy">
|
<Reference Include="Nancy">
|
||||||
<HintPath>..\packages\Nancy.1.4.1\lib\net40\Nancy.dll</HintPath>
|
<HintPath>..\packages\Nancy.1.4.1\lib\net40\Nancy.dll</HintPath>
|
||||||
</Reference>
|
</Reference>
|
||||||
|
@ -71,10 +91,6 @@
|
||||||
<Reference Include="Nancy.ViewEngines.Razor">
|
<Reference Include="Nancy.ViewEngines.Razor">
|
||||||
<HintPath>..\packages\Nancy.Viewengines.Razor.1.4.1\lib\net40\Nancy.ViewEngines.Razor.dll</HintPath>
|
<HintPath>..\packages\Nancy.Viewengines.Razor.1.4.1\lib\net40\Nancy.ViewEngines.Razor.dll</HintPath>
|
||||||
</Reference>
|
</Reference>
|
||||||
<Reference Include="Newtonsoft.Json, Version=7.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
|
|
||||||
<HintPath>..\packages\Newtonsoft.Json.7.0.1\lib\net45\Newtonsoft.Json.dll</HintPath>
|
|
||||||
<Private>True</Private>
|
|
||||||
</Reference>
|
|
||||||
<Reference Include="Owin, Version=1.0.0.0, Culture=neutral, PublicKeyToken=f0ebd12fd5e55cc5, processorArchitecture=MSIL">
|
<Reference Include="Owin, Version=1.0.0.0, Culture=neutral, PublicKeyToken=f0ebd12fd5e55cc5, processorArchitecture=MSIL">
|
||||||
<HintPath>..\packages\Owin.1.0\lib\net40\Owin.dll</HintPath>
|
<HintPath>..\packages\Owin.1.0\lib\net40\Owin.dll</HintPath>
|
||||||
<Private>True</Private>
|
<Private>True</Private>
|
||||||
|
@ -84,8 +100,11 @@
|
||||||
<Private>True</Private>
|
<Private>True</Private>
|
||||||
</Reference>
|
</Reference>
|
||||||
<Reference Include="System" />
|
<Reference Include="System" />
|
||||||
|
<Reference Include="System.Configuration" />
|
||||||
<Reference Include="System.Core" />
|
<Reference Include="System.Core" />
|
||||||
|
<Reference Include="System.Data" />
|
||||||
<Reference Include="System.Web" />
|
<Reference Include="System.Web" />
|
||||||
|
<Reference Include="System.Web.Extensions" />
|
||||||
<Reference Include="System.Web.Razor, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
|
<Reference Include="System.Web.Razor, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
|
||||||
<Private>True</Private>
|
<Private>True</Private>
|
||||||
<HintPath>..\packages\Microsoft.AspNet.Razor.2.0.30506.0\lib\net40\System.Web.Razor.dll</HintPath>
|
<HintPath>..\packages\Microsoft.AspNet.Razor.2.0.30506.0\lib\net40\System.Web.Razor.dll</HintPath>
|
||||||
|
@ -137,6 +156,9 @@
|
||||||
<Content Include="Content\jquery-2.2.1.min.js">
|
<Content Include="Content\jquery-2.2.1.min.js">
|
||||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
</Content>
|
</Content>
|
||||||
|
<Content Include="Content\requests.js">
|
||||||
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
|
</Content>
|
||||||
<Content Include="Content\site.js">
|
<Content Include="Content\site.js">
|
||||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
</Content>
|
</Content>
|
||||||
|
@ -188,6 +210,9 @@
|
||||||
<Content Include="Views\Login\Register.cshtml">
|
<Content Include="Views\Login\Register.cshtml">
|
||||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||||
</Content>
|
</Content>
|
||||||
|
<Content Include="Views\Requests\Index.cshtml">
|
||||||
|
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||||
|
</Content>
|
||||||
<None Include="Web.Debug.config">
|
<None Include="Web.Debug.config">
|
||||||
<DependentUpon>web.config</DependentUpon>
|
<DependentUpon>web.config</DependentUpon>
|
||||||
</None>
|
</None>
|
||||||
|
@ -197,7 +222,6 @@
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Folder Include="Auth\" />
|
<Folder Include="Auth\" />
|
||||||
<Folder Include="Views\Requests\" />
|
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ProjectReference Include="..\RequestPlex.Api\RequestPlex.Api.csproj">
|
<ProjectReference Include="..\RequestPlex.Api\RequestPlex.Api.csproj">
|
||||||
|
@ -208,6 +232,10 @@
|
||||||
<Project>{DD7DC444-D3BF-4027-8AB9-EFC71F5EC581}</Project>
|
<Project>{DD7DC444-D3BF-4027-8AB9-EFC71F5EC581}</Project>
|
||||||
<Name>RequestPlex.Core</Name>
|
<Name>RequestPlex.Core</Name>
|
||||||
</ProjectReference>
|
</ProjectReference>
|
||||||
|
<ProjectReference Include="..\RequestPlex.Helpers\RequestPlex.Helpers.csproj">
|
||||||
|
<Project>{1252336D-42A3-482A-804C-836E60173DFA}</Project>
|
||||||
|
<Name>RequestPlex.Helpers</Name>
|
||||||
|
</ProjectReference>
|
||||||
<ProjectReference Include="..\RequestPlex.Store\RequestPlex.Store.csproj">
|
<ProjectReference Include="..\RequestPlex.Store\RequestPlex.Store.csproj">
|
||||||
<Project>{92433867-2B7B-477B-A566-96C382427525}</Project>
|
<Project>{92433867-2B7B-477B-A566-96C382427525}</Project>
|
||||||
<Name>RequestPlex.Store</Name>
|
<Name>RequestPlex.Store</Name>
|
||||||
|
@ -218,6 +246,18 @@
|
||||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
</Content>
|
</Content>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<BootstrapperPackage Include=".NETFramework,Version=v4.5.2">
|
||||||
|
<Visible>False</Visible>
|
||||||
|
<ProductName>Microsoft .NET Framework 4.5.2 %28x86 and x64%29</ProductName>
|
||||||
|
<Install>true</Install>
|
||||||
|
</BootstrapperPackage>
|
||||||
|
<BootstrapperPackage Include="Microsoft.Net.Framework.3.5.SP1">
|
||||||
|
<Visible>False</Visible>
|
||||||
|
<ProductName>.NET Framework 3.5 SP1</ProductName>
|
||||||
|
<Install>false</Install>
|
||||||
|
</BootstrapperPackage>
|
||||||
|
</ItemGroup>
|
||||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<PostBuildEvent>
|
<PostBuildEvent>
|
||||||
|
|
|
@ -1,4 +1,6 @@
|
||||||
using Owin;
|
using System;
|
||||||
|
|
||||||
|
using Owin;
|
||||||
|
|
||||||
namespace RequestPlex.UI
|
namespace RequestPlex.UI
|
||||||
{
|
{
|
||||||
|
@ -6,7 +8,16 @@ namespace RequestPlex.UI
|
||||||
{
|
{
|
||||||
public void Configuration(IAppBuilder app)
|
public void Configuration(IAppBuilder app)
|
||||||
{
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
app.UseNancy();
|
app.UseNancy();
|
||||||
|
}
|
||||||
|
catch (Exception exception)
|
||||||
|
{
|
||||||
|
Console.WriteLine(exception.Message);
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
@{
|
@{
|
||||||
int port;
|
int port;
|
||||||
var authToken = string.Empty;
|
var authToken = string.Empty;
|
||||||
if (Model.Port == null)
|
if (Model.Port == 0)
|
||||||
{
|
{
|
||||||
port = 3579;
|
port = 3579;
|
||||||
}
|
}
|
||||||
|
@ -44,7 +44,7 @@
|
||||||
<input type="text" class="form-control" id="username" name="Username" placeholder="Username">
|
<input type="text" class="form-control" id="username" name="Username" placeholder="Username">
|
||||||
</div>
|
</div>
|
||||||
<div class="col-lg-4 col-lg-push-1">
|
<div class="col-lg-4 col-lg-push-1">
|
||||||
<input type="password" class="form-control" id="password" name="Username" placeholder="Password">
|
<input type="password" class="form-control" id="password" name="Password" placeholder="Password">
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
|
@ -69,10 +69,10 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<br/>
|
<br />
|
||||||
<br/>
|
<br />
|
||||||
<br/>
|
<br />
|
||||||
<br/>
|
<br />
|
||||||
<div>
|
<div>
|
||||||
<small class="col-lg-10 col-lg-offset-2">Please note, you will have to restart after changing these settings.</small>
|
<small class="col-lg-10 col-lg-offset-2">Please note, you will have to restart after changing these settings.</small>
|
||||||
</div>
|
</div>
|
||||||
|
@ -98,9 +98,11 @@
|
||||||
<script>
|
<script>
|
||||||
$(function () {
|
$(function () {
|
||||||
|
|
||||||
|
if ($('#PlexAuthToken')) {
|
||||||
loadUserList();
|
loadUserList();
|
||||||
|
}
|
||||||
|
|
||||||
$('#refreshUsers').click(function() {
|
$('#refreshUsers').click(function () {
|
||||||
loadUserList();
|
loadUserList();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
63
RequestPlex.UI/Views/Requests/Index.cshtml
Normal file
63
RequestPlex.UI/Views/Requests/Index.cshtml
Normal file
|
@ -0,0 +1,63 @@
|
||||||
|
<div>
|
||||||
|
<h2>Requests</h2>
|
||||||
|
<!-- Nav tabs -->
|
||||||
|
<ul id="nav-tabs" class="nav nav-tabs" role="tablist">
|
||||||
|
<li role="presentation" class="active"><a href="#MoviesTab" aria-controls="home" role="tab" data-toggle="tab">Movies</a></li>
|
||||||
|
<li role="presentation"><a href="#TvShowTab" aria-controls="profile" role="tab" data-toggle="tab">TV Shows</a></li>
|
||||||
|
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
<!-- Tab panes -->
|
||||||
|
<div class="tab-content">
|
||||||
|
|
||||||
|
<!-- Movie tab -->
|
||||||
|
<div role="tabpanel" class="tab-pane active" id="MoviesTab">
|
||||||
|
<br />
|
||||||
|
<br />
|
||||||
|
<!-- Movie content -->
|
||||||
|
<div id="movieList">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- TV tab -->
|
||||||
|
<div role="tabpanel" class="tab-pane" id="TvShowTab">
|
||||||
|
<br />
|
||||||
|
<br />
|
||||||
|
<!-- TV content -->
|
||||||
|
<div id="tvList">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
<script id="search-template" type="text/x-handlebars-template">
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-sm-2">
|
||||||
|
{{#if posterPath}}
|
||||||
|
<img src="http://image.tmdb.org/t/p/w150/{{posterPath}}" alt="poster">
|
||||||
|
{{/if}}
|
||||||
|
</div>
|
||||||
|
<div class="col-sm-5 ">
|
||||||
|
<div>
|
||||||
|
<a href="https://www.themoviedb.org/{{type}}/{{id}}">
|
||||||
|
<h4>{{title}} ({{year}})</h4>
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
<p>{{overview}}</p>
|
||||||
|
</div>
|
||||||
|
<div class="col-sm-2 col-sm-push-3">
|
||||||
|
<span class="label label-success">{{status}}</span>
|
||||||
|
<form method="POST" action="/search/request/{{type}}" id="form{{id}}">
|
||||||
|
<input name="{{type}}Id" type="text" value="{{id}}" hidden="hidden" />
|
||||||
|
<button id="{{id}}" style="text-align: right" class="btn btn-primary requestMovie" type="submit"><i class="fa fa-plus"></i> TestBtn</button>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
<hr />
|
||||||
|
</script>
|
||||||
|
|
||||||
|
|
||||||
|
<script src="/Content/requests.js" type="text/javascript"></script>
|
|
@ -51,20 +51,37 @@
|
||||||
<img src="http://image.tmdb.org/t/p/w150/{{posterPath}}" alt="poster">
|
<img src="http://image.tmdb.org/t/p/w150/{{posterPath}}" alt="poster">
|
||||||
{{/if}}
|
{{/if}}
|
||||||
</div>
|
</div>
|
||||||
<div class="col-sm-5">
|
<div class="col-sm-5 ">
|
||||||
<div>
|
<div>
|
||||||
<a href="https://www.themoviedb.org/{{type}}/{{id}}">
|
<a href="https://www.themoviedb.org/{{type}}/{{id}}">
|
||||||
<h4>{{title}} ({{year}})</h4>
|
<h4>{{title}} ({{year}})</h4>
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
<p>{{overview}}.</p>
|
<p>{{overview}}</p>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-sm-5">
|
<div class="col-sm-2 col-sm-push-3">
|
||||||
<small>Vote Average: {{voteAverage}}</small>
|
|
||||||
<small>Vote Count: {{voteCount}}</small>
|
|
||||||
<form method="POST" action="/search/request/{{type}}" id="form{{id}}">
|
<form method="POST" action="/search/request/{{type}}" id="form{{id}}">
|
||||||
<input name="{{type}}Id" type="text" value="{{id}}" hidden="hidden"/>
|
<input name="{{type}}Id" type="text" value="{{id}}" hidden="hidden" />
|
||||||
<button id="test" style="text-align: right" class="btn btn-primary bottom-align-text requestClass" type="submit"><i class="fa fa-plus"></i>Request</button>
|
{{#if_eq type "movie"}}
|
||||||
|
<button id="{{id}}" style="text-align: right" class="btn btn-primary requestMovie" type="submit"><i class="fa fa-plus"></i> Request</button>
|
||||||
|
{{/if_eq}}
|
||||||
|
{{#if_eq type "tv"}}
|
||||||
|
<div class="dropdown">
|
||||||
|
<button class="btn btn-primary dropdown-toggle" type="button" id="dropdownMenu1" data-toggle="dropdown" aria-haspopup="true" aria-expanded="true">
|
||||||
|
<i class="fa fa-plus"></i> Request
|
||||||
|
<span class="caret"></span>
|
||||||
|
</button>
|
||||||
|
<ul class="dropdown-menu" aria-labelledby="dropdownMenu1">
|
||||||
|
<li><a id="{{id}}" season-select="0" class="dropdownTv " href="#">All Seasons</a></li>
|
||||||
|
<li><a id="{{id}}" season-select="1" class="dropdownTv" href="#">Latest Season</a></li>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
{{/if_eq}}
|
||||||
|
<br />
|
||||||
|
<br />
|
||||||
|
<br />
|
||||||
|
<small class="row">Vote Average: {{voteAverage}}</small>
|
||||||
|
<small class="row">Vote Count: {{voteCount}}</small>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
|
@ -1,19 +1,31 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<configuration>
|
<configuration>
|
||||||
<configSections>
|
<configSections>
|
||||||
<sectionGroup name="system.web.webPages.razor" type="System.Web.WebPages.Razor.Configuration.RazorWebSectionGroup, System.Web.WebPages.Razor, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
|
<sectionGroup name="system.web.webPages.razor" type="System.Web.WebPages.Razor.Configuration.RazorWebSectionGroup, System.Web.WebPages.Razor, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
|
||||||
<section name="pages" type="System.Web.WebPages.Razor.Configuration.RazorPagesSection, System.Web.WebPages.Razor, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" />
|
<section name="pages" type="System.Web.WebPages.Razor.Configuration.RazorPagesSection, System.Web.WebPages.Razor, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" />
|
||||||
</sectionGroup>
|
</sectionGroup>
|
||||||
</configSections>
|
</configSections>
|
||||||
|
<appSettings>
|
||||||
<appSettings>
|
<add key="webPages:Enabled" value="false" />
|
||||||
<add key="webPages:Enabled" value="false" />
|
<add key="ClientSettingsProvider.ServiceUri" value="" />
|
||||||
</appSettings>
|
</appSettings>
|
||||||
<system.web.webPages.razor>
|
<system.web.webPages.razor>
|
||||||
<pages pageBaseType="Nancy.ViewEngines.Razor.NancyRazorViewBase">
|
<pages pageBaseType="Nancy.ViewEngines.Razor.NancyRazorViewBase">
|
||||||
<namespaces>
|
<namespaces>
|
||||||
<add namespace="Nancy.ViewEngines.Razor" />
|
<add namespace="Nancy.ViewEngines.Razor" />
|
||||||
</namespaces>
|
</namespaces>
|
||||||
</pages>
|
</pages>
|
||||||
</system.web.webPages.razor>
|
</system.web.webPages.razor>
|
||||||
|
<system.web>
|
||||||
|
<membership defaultProvider="ClientAuthenticationMembershipProvider">
|
||||||
|
<providers>
|
||||||
|
<add name="ClientAuthenticationMembershipProvider" type="System.Web.ClientServices.Providers.ClientFormsAuthenticationMembershipProvider, System.Web.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" serviceUri="" />
|
||||||
|
</providers>
|
||||||
|
</membership>
|
||||||
|
<roleManager defaultProvider="ClientRoleProvider" enabled="true">
|
||||||
|
<providers>
|
||||||
|
<add name="ClientRoleProvider" type="System.Web.ClientServices.Providers.ClientRoleProvider, System.Web.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" serviceUri="" cacheTimeout="86400" />
|
||||||
|
</providers>
|
||||||
|
</roleManager>
|
||||||
|
</system.web>
|
||||||
</configuration>
|
</configuration>
|
|
@ -10,7 +10,6 @@
|
||||||
<package id="Nancy.Hosting.Self" version="1.4.1" requireReinstallation="true" />
|
<package id="Nancy.Hosting.Self" version="1.4.1" requireReinstallation="true" />
|
||||||
<package id="Nancy.Owin" version="1.4.1" targetFramework="net452" />
|
<package id="Nancy.Owin" version="1.4.1" targetFramework="net452" />
|
||||||
<package id="Nancy.Viewengines.Razor" version="1.4.1" requireReinstallation="true" />
|
<package id="Nancy.Viewengines.Razor" version="1.4.1" requireReinstallation="true" />
|
||||||
<package id="Newtonsoft.Json" version="7.0.1" targetFramework="net452" />
|
|
||||||
<package id="Owin" version="1.0" targetFramework="net452" />
|
<package id="Owin" version="1.0" targetFramework="net452" />
|
||||||
<package id="RestSharp" version="105.2.3" targetFramework="net452" />
|
<package id="RestSharp" version="105.2.3" targetFramework="net452" />
|
||||||
<package id="TMDbLib" version="0.9.0.0-alpha" targetFramework="net452" />
|
<package id="TMDbLib" version="0.9.0.0-alpha" targetFramework="net452" />
|
||||||
|
|
|
@ -19,6 +19,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
|
||||||
README.md = README.md
|
README.md = README.md
|
||||||
EndProjectSection
|
EndProjectSection
|
||||||
EndProject
|
EndProject
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RequestPlex.Helpers", "RequestPlex.Helpers\RequestPlex.Helpers.csproj", "{1252336D-42A3-482A-804C-836E60173DFA}"
|
||||||
|
EndProject
|
||||||
Global
|
Global
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
Debug|Any CPU = Debug|Any CPU
|
Debug|Any CPU = Debug|Any CPU
|
||||||
|
@ -45,6 +47,10 @@ Global
|
||||||
{92433867-2B7B-477B-A566-96C382427525}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
{92433867-2B7B-477B-A566-96C382427525}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
{92433867-2B7B-477B-A566-96C382427525}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
{92433867-2B7B-477B-A566-96C382427525}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
{92433867-2B7B-477B-A566-96C382427525}.Release|Any CPU.Build.0 = Release|Any CPU
|
{92433867-2B7B-477B-A566-96C382427525}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{1252336D-42A3-482A-804C-836E60173DFA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{1252336D-42A3-482A-804C-836E60173DFA}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{1252336D-42A3-482A-804C-836E60173DFA}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{1252336D-42A3-482A-804C-836E60173DFA}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(SolutionProperties) = preSolution
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
HideSolutionNode = FALSE
|
HideSolutionNode = FALSE
|
||||||
|
|
27
RequestPlex.sln.DotSettings
Normal file
27
RequestPlex.sln.DotSettings
Normal file
|
@ -0,0 +1,27 @@
|
||||||
|
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
|
||||||
|
<s:String x:Key="/Default/CodeStyle/FileHeader/FileHeaderText/@EntryValue">/************************************************************************
|
||||||
|
Copyright (c) $CURRENT_YEAR$ Jamie Rees
|
||||||
|
File: $FILENAME$
|
||||||
|
Created By: $USER_NAME$
|
||||||
|

|
||||||
|
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.
|
||||||
|
************************************************************************/
|
||||||
|
</s:String>
|
||||||
|
<s:String x:Key="/Default/CodeStyle/FileHeader/FileHeaderRegionName/@EntryValue">Copyright</s:String></wpf:ResourceDictionary>
|
Loading…
Add table
Add a link
Reference in a new issue