public CustomerCreateUpdateViewModel() { var allRoles = RoleNames.GetAllRoleNames().Select(r => new { RoleId = RoleNames.GetRoleIdByName(r), RoleName = r }).ToList(); RolesList = new MultiSelectList(allRoles, "RoleId", "RoleName", new int[] {}); }
public CustomerCreateUpdateViewModel(CustomerEntity customer) : base(customer) { var customerRoles = Roles.GetRolesForUser(Login); var allRoles = RoleNames.GetAllRoleNames().Select(r => new { RoleId = RoleNames.GetRoleIdByName(r), RoleName = r }).ToList(); var selectedRoles = customerRoles.Select(r => new { RoleId = RoleNames.GetRoleIdByName(r), RoleName = r }).ToList(); InititallySelectedRoles = selectedRoles.Select(r => r.RoleId).ToArray(); RolesList = new MultiSelectList(allRoles, "RoleId", "RoleName", InititallySelectedRoles); OldHashedPassword = customer.Password; // Workaround to deal with hased password that probably don't match pattern. _password = TempPassword; ConfirmPassword = TempPassword; }