public ProfileViewModel(Account account, IEnumerable <Role> roles) { this.Id = account.Id; this.Email = account.Email; this.FirstName = account.FirstName; this.LastName = account.LastName; this.PhoneNumber = account.PhoneNumber; this.Addresses = account.Address; this.Role = account.Role; foreach (var role in roles) { if (role.RoleName == this.Role.RoleName) { SelectListItem listItem = new SelectListItem() { Value = role.Id.ToString(), Text = role.RoleName }; CurrentRole.Add(listItem); } else { SelectListItem listItem = new SelectListItem() { Value = role.Id.ToString(), Text = role.RoleName }; OtherRole.Add(listItem); } } Roles.AddRange(CurrentRole); Roles.AddRange(OtherRole); }
//not currently being used, meant for matching role name to ID public void SetCurrentRole(List <Microsoft.AspNet.Identity.EntityFramework.IdentityRole> roles) { foreach (var role in roles) { CurrentRole.Add(role); } }