I am new to MVC 5 asp.net Identity model and was looking for means to customise standard Asp.net Identity to suit my needs. Through blog on TypeCast Exception and one at Stackoverflow: How to model Identity I was able to create my own elements in ApplicationUser and ApplicationRole tables. However, my requirement is to add new columns to UserRole table, DATE_FROM and DATE_TO which I did by implementing IdentityUserRole
interface. My problem is when I'm trying to save the link UserManager.AddRoleToUser takes only two parameters, UserName and RoleName. How to store parameters for custom ApplicationUserRole
?
public bool AddUserToRole(string userId, SelectUserRolesViewModel roleName)
{
var um = new UserManager<ApplicationUser>(
new UserStore<ApplicationUser>(new ApplicationDbContext()));
var idResult = um.AddToRole(userId, roleName);
return idResult.Succeeded;
}
the SelectUserRolesViewModel supplies extended IdnetityUserRole model. Any pointer will be appreciated.