Hello
I'm trying to "convert" this into a strongly typed model instead of ViewData. But how should that look?
I got this in my controller:
public ActionResult UserEdit(int? userID)
{
User u;
if (userID == null)
{
u = new User();
}
else
{
u = _us.GetUsers(userID.Value).First();
u.Usergroups.Load();
}
List<int> selectedUsergroupIDs = new List<int>();
foreach (Usergroup item in u.Usergroups)
{
selectedUsergroupIDs.Add(item.UsergroupID);
}
MultiSelectList UsergroupID = new MultiSelectList(_ug.GetUsergroups(), "UsergroupID", "UsergroupName", selectedUsergroupIDs);
ViewData["UsergroupID"] = UsergroupID;
return View("UserEdit", new UserAdminEditViewModel { User = u, Usergroups = _ug.GetUsergroups() });
}
"UsergroupID" in this case, what's needed to add in my model and in my view?
Thanks in advance
/M