-2
[HttpGet]
public ActionResult Edit(int id)
{
var userToEdit = _db.AuthLogin.Where(user => user.Id == id).SingleOrDefault();
if (userToEdit == null)
return HttpNotFound();
return View(new EditUser()
{
Email = userToEdit.Email,
UserName = userToEdit.UserName,
Password = userToEdit.Password,
Roles = _db.Roles.Select(role => new RoleCheckBox
{
Id = role.Id,
IsChecked = userToEdit.Roles.Contains(role),
Name = role.Name
}).ToList()
});
}