public IActionResult GetRole() { UserMapper mapper = new UserMapper(); AdminDataAccess adm = new AdminDataAccess(); List <RoleDTO> roles = adm.GetRoles(); List <RoleOutputModel> rolesOut = new List <RoleOutputModel>(); foreach (RoleDTO r in roles) { rolesOut.Add(mapper.ConvertRoleDTOToRoleOutputModel(r)); } return(Ok(rolesOut)); }
public IActionResult GetRolesByUserId(int userId) { AdminDataAccess adm = new AdminDataAccess(); List <RoleOutputModel> allUsers = new List <RoleOutputModel>(); UserMapper mapper = new UserMapper(); var roles = adm.GetRoleByUserId(userId); if (roles == null) { return(BadRequest("У пользователя нет ролей")); } foreach (RoleDTO role in adm.GetRoleByUserId(userId)) { allUsers.Add(mapper.ConvertRoleDTOToRoleOutputModel(role)); } return(Ok(allUsers)); }