Пример #1
0
        protected override IdentityRoleClaim <int> CreateRoleClaim(Role role, Claim claim)
        {
            var roleClaim = new RoleClaim
            {
                ClaimType  = claim.Type,
                ClaimValue = claim.Value,
                RoleId     = role.Id
            };

            Context.Set <RoleClaim>().Add(roleClaim);
            Context.SaveChanges();
            return(roleClaim);
        }
Пример #2
0
        //public iUserStore(UserContext context) : base(context) { }
        protected override UserRole CreateUserRole(Models.User user, Role role)
        {
            if (!Context.Set <UserRole>().Any(it => it.UserId == user.Id && role.Id == it.RoleId))
            {
                return(Context.Set <UserRole>().Single(it => it.UserId == user.Id && role.Id == it.RoleId));
            }
            var usrRole = new UserRole
            {
                RoleId = role.Id,
                UserId = user.Id
            };

            Context.Set <UserRole>().Add(usrRole);
            Context.SaveChanges();
            return(usrRole);
        }