public async Task createRoles([FromBody] UserRols userInfo) { string rolName = userInfo.RolName; bool x = await _roleManager.RoleExistsAsync(rolName); if (!x) { var role = new IdentityRole { Name = rolName }; await _roleManager.CreateAsync(role); } }
public void SetUser(string UserName) { this.ActualUser = GetUser(UserName); this.MenuViewModel = new MenuViewModel(this.ChagePage, this.ActualUser); this.UserRols = ""; if (this.ActualUser.USUARIO_ROL.Count > 0) { UserRols += "Roles actuales: "; } foreach (USUARIO_ROL s in this.ActualUser.USUARIO_ROL) { if (s.IS_ACTIVE) { if (s.ROL.IS_ACTIVE) { UserRols += s.ROL.ROL_NAME; UserRols += ", "; } } } if (UserRols.Equals("")) { UserRols = "No tienes roles asignados"; } else { string aux = ""; for (int i = 0; i < UserRols.Length - 3; i++) { aux += UserRols[i]; } UserRols = aux; } UserRols += "."; }