1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
|
public class AuthController
{
public async Task<Result> Register(string FullName, string MacAddress, string TripKey)
{
using (var client = new HttpClient())
{
client.BaseAddress = new Uri("http://localhost:59381/");
client.DefaultRequestHeaders.Accept.Clear();
UserRegisterViewModel user = new UserRegisterViewModel()
{
FullName = FullName,
MacAddress = MacAddress,
TripKey = TripKey
};
string json = JsonConvert.SerializeObject(user);
try
{
HttpResponseMessage response = await client.PostAsync("api/Account/Register", new StringContent(json));
return response.IsSuccessStatusCode ? new Result() : new Result(response.StatusCode + " - " + response.ReasonPhrase);
}
catch (Exception pEx)
{
return new Result(pEx);
}
}
}
} |
Partager