public ActionResult GetUserInfo() { var authorizationToken = this.Request.Headers["Authorization"].ToString(); if (authorizationToken == "") { return(Unauthorized()); } int id = Jwt.GetIdFromToken(authorizationToken); if (id == 0) { return(Unauthorized()); } dynamic result = Repository.GetInfo(id); if (result == null) { return(NotFound(new { message = "not found" })); } if (result.ToString() == "ERROR") { return(BadRequest(new { message = "Error" })); } foreach (var res in result) { return(Ok(res)); } return(Ok(result)); }
static void Main(string[] args) { EndpointAddress address = new EndpointAddress("http://localhost:1234/UserInfo"); WSHttpBinding binding = new WSHttpBinding(); ChannelFactory <IUserInfo> factory = new ChannelFactory <IUserInfo>(binding, address); IUserInfo channel = factory.CreateChannel(); User[] Users = channel.GetInfo(null); Console.WriteLine("{0,-10}{1,-10}{2,-10}{3,-10}", "ID", "Name", "Age", "Nationality"); for (int i = 0; i < Users.Length; i++) { Console.WriteLine("{0,-10}{1,-10}{2,-10}{3,-10}", Users[i].ID.ToString(), Users[i].Name.ToString(), Users[i].Age.ToString(), Users[i].Nationality.ToString()); } ((IChannel)channel).Close(); factory.Close(); Console.Read(); }