pull/687/head
Jamie.Rees 8 years ago
parent 6d2bc0eb72
commit 84ea45ebaa

@ -39,10 +39,6 @@ namespace PlexRequests.Core.Migration
foreach (var param in ctor.GetParameters()) foreach (var param in ctor.GetParameters())
{ {
Console.WriteLine(string.Format(
"Param {0} is named {1} and is of type {2}",
param.Position, param.Name, param.ParameterType));
var dep = Kernel.Get(param.ParameterType); var dep = Kernel.Get(param.ParameterType);
dependencies.Add(dep); dependencies.Add(dep);
} }

@ -26,6 +26,8 @@
#endregion #endregion
using System.Data; using System.Data;
using System.Linq;
using PlexRequests.Helpers.Permissions;
using PlexRequests.Store; using PlexRequests.Store;
using PlexRequests.Store.Repository; using PlexRequests.Store.Repository;
@ -36,17 +38,17 @@ namespace PlexRequests.Core.Migration.Migrations
{ {
public Version1100(IUserRepository userRepo) public Version1100(IUserRepository userRepo)
{ {
UserRepo = userRepo;
} }
public int Version => 11000; public int Version => 11000;
public IUserRepository UserRepo {get;set;} private IUserRepository UserRepo { get; }
public void Start(IDbConnection con) public void Start(IDbConnection con)
{ {
UpdateDb(con); UpdateDb(con);
// Update the current admin permissions set // Update the current admin permissions set
UpdateAdmin(con); UpdateAdmin();
UpdateSchema(con, Version); UpdateSchema(con, Version);
} }
@ -56,19 +58,24 @@ namespace PlexRequests.Core.Migration.Migrations
// Create the two new columns // Create the two new columns
con.AlterTable("Users", "ADD", "Permissions", true, "INTEGER"); con.AlterTable("Users", "ADD", "Permissions", true, "INTEGER");
con.AlterTable("Users", "ADD", "Features", true, "INTEGER"); con.AlterTable("Users", "ADD", "Features", true, "INTEGER");
} }
private void UpdateAdmin(IDbConnection con) private void UpdateAdmin()
{ {
var users = UserRepo.GetAll(); var users = UserRepo.GetAll().ToList();
foreach (var user in users) foreach (var user in users)
{ {
user.Permissions = Permissions.Administrator | ReportIssue | RequestMusic user.Permissions = (int)
| RequestTvShow (Permissions.Administrator
| RequestMovie; | Permissions.ReportIssue
| Permissions.RequestMusic
| Permissions.RequestTvShow
| Permissions.RequestMovie);
} }
UserRepo.UpdateAll(users);
} }
} }
} }

@ -74,6 +74,10 @@
<Project>{DD7DC444-D3BF-4027-8AB9-EFC71F5EC581}</Project> <Project>{DD7DC444-D3BF-4027-8AB9-EFC71F5EC581}</Project>
<Name>PlexRequests.Core</Name> <Name>PlexRequests.Core</Name>
</ProjectReference> </ProjectReference>
<ProjectReference Include="..\PlexRequests.Helpers\PlexRequests.Helpers.csproj">
<Project>{1252336D-42A3-482A-804C-836E60173DFA}</Project>
<Name>PlexRequests.Helpers</Name>
</ProjectReference>
<ProjectReference Include="..\PlexRequests.Store\PlexRequests.Store.csproj"> <ProjectReference Include="..\PlexRequests.Store\PlexRequests.Store.csproj">
<Project>{92433867-2B7B-477B-A566-96C382427525}</Project> <Project>{92433867-2B7B-477B-A566-96C382427525}</Project>
<Name>PlexRequests.Store</Name> <Name>PlexRequests.Store</Name>

@ -105,6 +105,9 @@ namespace PlexRequests.Store.Repository
IEnumerable<UsersModel> Custom(Func<IDbConnection, IEnumerable<UsersModel>> func); IEnumerable<UsersModel> Custom(Func<IDbConnection, IEnumerable<UsersModel>> func);
long Insert(UsersModel entity); long Insert(UsersModel entity);
void Delete(UsersModel entity); void Delete(UsersModel entity);
IEnumerable<UsersModel> GetAll();
bool UpdateAll(IEnumerable<UsersModel> entity);
bool Update(UsersModel entity);
} }
} }

Loading…
Cancel
Save