public UserRoleViewModel AutoMappingUserRoleViewModel(User selected) { RoleController rc = new RoleController(); var mapper = mapextension.UserToUserRoleViewModel(); UserRoleViewModel model = mapper.Map <UserRoleViewModel>(selected); model.RolesInUser = new List <RoleOverviewViewModel>(); foreach (Role r in rc.RetrieveRolesFromUser(selected)) { var mapperTwo = mapextension.RoleToRoleOverviewViewModel(); RoleOverviewViewModel rmodel = mapperTwo.Map <RoleOverviewViewModel>(r); model.RolesInUser.Add(rmodel); } model.AllUserRoles = new List <RoleOverviewViewModel>(); foreach (Role r in roleRep.RetrieveAllRoles()) { var mapperThree = mapextension.RoleToRoleOverviewViewModel(); RoleOverviewViewModel rmodel = mapperThree.Map <RoleOverviewViewModel>(r); model.AllUserRoles.Add(rmodel); } return(model); }