Advertisement
Guest User

Untitled

a guest
Jun 25th, 2019
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.42 KB | None | 0 0
  1. public async Task<IdentityResult> AssignRole(int userId, string roleName)
  2. {
  3. IUser usr = await this.DBContext.Context.IdentityUsers.FirstOrDefaultAsync(r => r.Id.Equals(userId));
  4.  
  5. this.DBContext.Context.Detach(usr);
  6.  
  7. var result = await _user.AddToRoleAsync((User)usr, roleName);
  8.  
  9. return result;
  10. }
  11.  
  12. public void Detach(ILCAssetsBase entity)
  13. {
  14. this.Entry(entity).State = EntityState.Detached;
  15. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement