Это мой Register Api:
publi c asyn c Task RegisterAsyn c (строка электронной почты, строка пароля, строка confirmPassword) {
var model = new RegisterBindingModel
{
Email = email,
Password = password,
ConfirmPassword = confirmPassword
};
try
{
var json = JsonConvert.SerializeObject(model);
HttpContent content = new StringContent(json);
content.Headers.ContentType = new MediaTypeHeaderValue("application/json");
var client = new HttpClient();
var response = await client.PostAsync("http://155.238.210.61:44382/api/Account/Register/", content);
if (response.IsSuccessStatusCode)
{
return true;
}
}
catch (SocketException ex)
{
Console.WriteLine("Oxception Occured" + ex);
}
return false;
}
== ================================================== ==============================
Моя модель просмотра:
publi c class RegisterViewModel {частные только для чтения ApiServices _apiService = new ApiServices ();
public string Email { get; set; }
public string Password { get; set; }
public string ConfirmPassword { get; set; }
public string Message { get; set; }
public ICommand RegisterCommand
{
get
{
return new Command(async () =>
{
var isSuccess = await _apiService.RegisterAsync(Email, Password, ConfirmPassword);
Settings.Email = Email;
Settings.Password = Password;
//ClearFields();
if (isSuccess)
Message = "Registered Successfully";
else
Message = "Error Occured, Please try Again";
});
}
}
}
}
===================== ==================== Класс помощника:
publi c stati c class Settings {private stati c ISettings AppSettings {get { return CrossSettings.Current; }}
public static string Email
{
get
{
return AppSettings.GetValueOrDefault("Email", "");
}
set
{
AppSettings.AddOrUpdateValue("Email", value);
}
}
public static string Password
{
get
{
return AppSettings.GetValueOrDefault("Password", "");
}
set
{
AppSettings.AddOrUpdateValue("Password", value);
}
}
public static DateTime AccessTokenExpirationDate
{
get
{
return AppSettings.GetValueOrDefault("AccessTokenExpirationDate", DateTime.UtcNow);
}
set
{
AppSettings.AddOrUpdateValue("AccessTokenExpirationDate", value);
}
}
public static string AccessToken
{
get
{
return AppSettings.GetValueOrDefault("AccessToken", "");
}
set
{
AppSettings.AddOrUpdateValue("AccessToken", value);
}
}
}
========================= Веб-API подключен к Sql БД сервера