moved everything up a directory

This commit is contained in:
tidusjar 2016-02-26 14:31:28 +00:00
commit 9a78f790a6
76 changed files with 0 additions and 0 deletions

View 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.Core")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("RequestPlex.Core")]
[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("dd7dc444-d3bf-4027-8ab9-efc71f5ec581")]
// 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")]

View file

@ -0,0 +1,77 @@
<?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>{DD7DC444-D3BF-4027-8AB9-EFC71F5EC581}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>RequestPlex.Core</RootNamespace>
<AssemblyName>RequestPlex.Core</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="Mono.Data.Sqlite">
<HintPath>..\Assemblies\Mono.Data.Sqlite.dll</HintPath>
</Reference>
<Reference Include="Nancy, Version=1.4.2.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Nancy.1.4.3\lib\net40\Nancy.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Nancy.Authentication.Forms, Version=1.4.1.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Nancy.Authentication.Forms.1.4.1\lib\net40\Nancy.Authentication.Forms.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<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="SettingsService.cs" />
<Compile Include="Setup.cs" />
<Compile Include="UserIdentity.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="UserMapper.cs" />
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\RequestPlex.Store\RequestPlex.Store.csproj">
<Project>{92433867-2B7B-477B-A566-96C382427525}</Project>
<Name>RequestPlex.Store</Name>
</ProjectReference>
</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>

View file

@ -0,0 +1,42 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Mono.Data.Sqlite;
using RequestPlex.Store;
namespace RequestPlex.Core
{
public class SettingsService
{
public void SaveSettings(int port)
{
var db = new DbConfiguration(new SqliteFactory());
var repo = new GenericRepository<SettingsModel>(db);
var existingSettings = repo.GetAll().FirstOrDefault();
if (existingSettings != null)
{
existingSettings.Port = port;
repo.Update(existingSettings);
return;
}
var newSettings = new SettingsModel { Port = port };
repo.Insert(newSettings);
}
public SettingsModel GetSettings()
{
var db = new DbConfiguration(new SqliteFactory());
var repo = new GenericRepository<SettingsModel>(db);
var settings = repo.GetAll().FirstOrDefault();
return settings;
}
}
}

17
RequestPlex.Core/Setup.cs Normal file
View file

@ -0,0 +1,17 @@
using Mono.Data.Sqlite;
using RequestPlex.Store;
namespace RequestPlex.Core
{
public class Setup
{
public void SetupDb()
{
var db = new DbConfiguration(new SqliteFactory());
db.CreateDatabase();
TableCreation.CreateTables(db.DbConnection());
}
}
}

View file

@ -0,0 +1,16 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Nancy.Security;
namespace RequestPlex.Core
{
public class UserIdentity : IUserIdentity
{
public string UserName { get; set; }
public IEnumerable<string> Claims { get; set; }
}
}

View file

@ -0,0 +1,71 @@
using System;
using System.Linq;
using Mono.Data.Sqlite;
using Nancy;
using Nancy.Authentication.Forms;
using Nancy.Security;
using RequestPlex.Store;
namespace RequestPlex.Core
{
public class UserMapper : IUserMapper
{
public IUserIdentity GetUserFromIdentifier(Guid identifier, NancyContext context)
{
var db = new DbConfiguration(new SqliteFactory());
var repo = new UserRepository<UserModel>(db);
var user = repo.Get(identifier.ToString());
if (user == null)
{
return null;
}
return new UserIdentity
{
UserName = user.UserName,
};
}
public static Guid? ValidateUser(string username, string password)
{
var db = new DbConfiguration(new SqliteFactory());
var repo = new UserRepository<UserModel>(db);
var users = repo.GetAll();
var userRecord = users.FirstOrDefault(u => u.UserName == username && u.Password == password); // TODO hashing
if (userRecord == null)
{
return null;
}
return new Guid(userRecord.User);
}
public static bool DoUsersExist()
{
var db = new DbConfiguration(new SqliteFactory());
var repo = new UserRepository<UserModel>(db);
var users = repo.GetAll();
return users.Any();
}
public static Guid? CreateUser(string username, string password)
{
var db = new DbConfiguration(new SqliteFactory());
var repo = new UserRepository<UserModel>(db);
var userModel = new UserModel { UserName = username, User = Guid.NewGuid().ToString(), Password = password };
repo.Insert(userModel);
var userRecord = repo.Get(userModel.User);
return new Guid(userRecord.User);
}
}
}

View file

@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Nancy" version="1.4.3" targetFramework="net452" />
<package id="Nancy.Authentication.Forms" version="1.4.1" targetFramework="net452" />
</packages>