User management stuff

This commit is contained in:
Jamie.Rees 2016-10-25 17:31:59 +01:00
commit b851d77364
17 changed files with 232 additions and 94 deletions

View file

@ -87,6 +87,7 @@
<Compile Include="Repository\GenericRepository.cs" />
<Compile Include="RequestedModel.cs" />
<Compile Include="UserEntity.cs" />
<Compile Include="UserLogins.cs" />
<Compile Include="UsersModel.cs" />
<Compile Include="UserRepository.cs" />
<Compile Include="Sql.Designer.cs">

View file

@ -11,6 +11,15 @@ CREATE TABLE IF NOT EXISTS Users
UserProperties BLOB
);
CREATE TABLE IF NOT EXISTS UserLogins
(
Id INTEGER PRIMARY KEY AUTOINCREMENT,
UserId varchar(50) NOT NULL ,
Type INTEGER NOT NULL,
LastLoggedIn varchar(100) NOT NULL
);
CREATE INDEX IF NOT EXISTS UserLogins_UserId ON UserLogins (UserId);
CREATE TABLE IF NOT EXISTS GlobalSettings
(

View file

@ -57,7 +57,7 @@ namespace PlexRequests.Store
}
}
public static void AddColumn(this IDbConnection connection, string tableName, string alterType, string newColumn, bool isNullable, string dataType)
public static void AddColumn(this IDbConnection connection, string tableName, string alterType, string newColumn, bool allowNulls, string dataType)
{
connection.Open();
var result = connection.Query<TableInfo>($"PRAGMA table_info({tableName});");
@ -67,7 +67,7 @@ namespace PlexRequests.Store
}
var query = $"ALTER TABLE {tableName} {alterType} {newColumn} {dataType}";
if (isNullable)
if (!allowNulls)
{
query = query + " NOT NULL";
}

View file

@ -0,0 +1,41 @@
#region Copyright
// /************************************************************************
// Copyright (c) 2016 Jamie Rees
// File: UserLogins.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 Dapper.Contrib.Extensions;
using PlexRequests.Helpers;
namespace PlexRequests.Store
{
[Table("UserLogins")]
public class UserLogins : Entity
{
public string UserId { get; set; }
public UserType Type { get; set; }
public DateTime LastLoggedIn { get; set; }
}
}

View file

@ -24,6 +24,8 @@
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
// ************************************************************************/
#endregion
using System;
using Dapper.Contrib.Extensions;
namespace PlexRequests.Store