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())
{
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);
dependencies.Add(dep);
}

@ -26,6 +26,8 @@
#endregion
using System.Data;
using System.Linq;
using PlexRequests.Helpers.Permissions;
using PlexRequests.Store;
using PlexRequests.Store.Repository;
@ -36,17 +38,17 @@ namespace PlexRequests.Core.Migration.Migrations
{
public Version1100(IUserRepository userRepo)
{
UserRepo = userRepo;
}
public int Version => 11000;
public IUserRepository UserRepo {get;set;}
private IUserRepository UserRepo { get; }
public void Start(IDbConnection con)
{
UpdateDb(con);
// Update the current admin permissions set
UpdateAdmin(con);
UpdateAdmin();
UpdateSchema(con, Version);
}
@ -59,16 +61,21 @@ namespace PlexRequests.Core.Migration.Migrations
}
private void UpdateAdmin(IDbConnection con)
private void UpdateAdmin()
{
var users = UserRepo.GetAll();
var users = UserRepo.GetAll().ToList();
foreach (var user in users)
{
user.Permissions = Permissions.Administrator | ReportIssue | RequestMusic
| RequestTvShow
| RequestMovie;
user.Permissions = (int)
(Permissions.Administrator
| Permissions.ReportIssue
| Permissions.RequestMusic
| Permissions.RequestTvShow
| Permissions.RequestMovie);
}
UserRepo.UpdateAll(users);
}
}
}

@ -74,6 +74,10 @@
<Project>{DD7DC444-D3BF-4027-8AB9-EFC71F5EC581}</Project>
<Name>PlexRequests.Core</Name>
</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">
<Project>{92433867-2B7B-477B-A566-96C382427525}</Project>
<Name>PlexRequests.Store</Name>

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

Loading…
Cancel
Save