0
hello guys I am finding it difficult to update the user role when updating my data, my roles are being filled by a Viewbag in my get from my controller and I am retrieving the new ID from my controller post via the request.form follow the code from my post.
[AllowAnonymous]
[HttpPost]
public ActionResult UserEdit(ApplicationUser appuser)
{
var context = new Models.ApplicationDbContext();
var user = context.Users.Where(u => u.Id == appuser.Id).FirstOrDefault();
user.LockoutEnabled = appuser.LockoutEnabled;
//Recupera o ID do novo item
var newRole = Request.Form["RoleId"].ToString();
//Aqui eu deveria a atualização da role
context.SaveChanges();
return RedirectToAction("UserList");
}
thank you all.