develop #10
@ -7,12 +7,19 @@ using Android.Views;
|
|||||||
using Android.Widget;
|
using Android.Widget;
|
||||||
using Android.OS;
|
using Android.OS;
|
||||||
using Xamarin.Essentials;
|
using Xamarin.Essentials;
|
||||||
|
using System.Net.Http;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Security;
|
||||||
|
using System.Net;
|
||||||
|
using System.Linq;
|
||||||
|
|
||||||
namespace Klient.Droid
|
namespace Klient.Droid
|
||||||
{
|
{
|
||||||
[Activity(Label = "Klient", Icon = "@mipmap/icon", Theme = "@style/MainTheme", MainLauncher = true, ConfigurationChanges = ConfigChanges.ScreenSize | ConfigChanges.Orientation)]
|
[Activity(Label = "Klient", Icon = "@mipmap/icon", Theme = "@style/MainTheme", MainLauncher = true, ConfigurationChanges = ConfigChanges.ScreenSize | ConfigChanges.Orientation)]
|
||||||
public class MainActivity : global::Xamarin.Forms.Platform.Android.FormsAppCompatActivity
|
public class MainActivity : global::Xamarin.Forms.Platform.Android.FormsAppCompatActivity
|
||||||
{
|
{
|
||||||
|
private static readonly HttpClient client = new HttpClient();
|
||||||
|
|
||||||
protected override void OnCreate(Bundle savedInstanceState)
|
protected override void OnCreate(Bundle savedInstanceState)
|
||||||
{
|
{
|
||||||
base.OnCreate(savedInstanceState);
|
base.OnCreate(savedInstanceState);
|
||||||
@ -24,7 +31,29 @@ namespace Klient.Droid
|
|||||||
[Java.Interop.Export("In")]
|
[Java.Interop.Export("In")]
|
||||||
async public void SignIn(View v)
|
async public void SignIn(View v)
|
||||||
{
|
{
|
||||||
|
var Login = FindViewById<EditText>(Resource.Id.Login).Text;
|
||||||
|
SecureString Password = new NetworkCredential("", FindViewById<EditText>(Resource.Id.Password).Text).SecurePassword;
|
||||||
|
|
||||||
|
if(Login.Length < 3 || Login.Length > 12)
|
||||||
|
{
|
||||||
|
SetContentView(Resource.Layout.ekranLogowania);
|
||||||
|
}
|
||||||
|
if(string.IsNullOrWhiteSpace(new NetworkCredential("", Password).Password))
|
||||||
|
{
|
||||||
|
SetContentView(Resource.Layout.ekranLogowania);
|
||||||
|
}
|
||||||
|
|
||||||
|
var values = new Dictionary<string, string>
|
||||||
|
{
|
||||||
|
{ "login", Login },
|
||||||
|
{ "password", new NetworkCredential("", Password).Password }
|
||||||
|
};
|
||||||
|
|
||||||
|
var content = new FormUrlEncodedContent(values);
|
||||||
|
|
||||||
|
var response = await client.PostAsync("https://localhost:44371/api/User/SignIn", content);
|
||||||
|
|
||||||
|
var responseString = await response.Content.ReadAsStringAsync();
|
||||||
}
|
}
|
||||||
|
|
||||||
[Java.Interop.Export("Reset")]
|
[Java.Interop.Export("Reset")]
|
||||||
@ -36,7 +65,32 @@ namespace Klient.Droid
|
|||||||
[Java.Interop.Export("SignUp")]
|
[Java.Interop.Export("SignUp")]
|
||||||
async public void SignUp()
|
async public void SignUp()
|
||||||
{
|
{
|
||||||
|
var Name = FindViewById<EditText>(Resource.Id.Name).Text;
|
||||||
|
var Surname = FindViewById<EditText>(Resource.Id.Surname).Text;
|
||||||
|
var Email = FindViewById<EditText>(Resource.Id.Email).Text;
|
||||||
|
var Login = FindViewById<EditText>(Resource.Id.NewLogin).Text;
|
||||||
|
SecureString Password = new NetworkCredential("", FindViewById<EditText>(Resource.Id.NewPassword).Text).SecurePassword;
|
||||||
|
SecureString Password2 = new NetworkCredential("", FindViewById<EditText>(Resource.Id.RepeatPassword).Text).SecurePassword;
|
||||||
|
|
||||||
|
if(new NetworkCredential("", Password).Password != new NetworkCredential("", Password2).Password)
|
||||||
|
{
|
||||||
|
SetContentView(Resource.Layout.ekranRejestracji);
|
||||||
|
}
|
||||||
|
|
||||||
|
var values = new Dictionary<string, string>
|
||||||
|
{
|
||||||
|
{ "email", Email },
|
||||||
|
{ "name", Name },
|
||||||
|
{ "surname", Surname },
|
||||||
|
{ "login", Login },
|
||||||
|
{ "password", new NetworkCredential("", Password).Password }
|
||||||
|
};
|
||||||
|
|
||||||
|
var content = new FormUrlEncodedContent(values);
|
||||||
|
|
||||||
|
var response = await client.PostAsync("https://localhost:44371/api/User/Register", content);
|
||||||
|
|
||||||
|
var responseString = await response.Content.ReadAsStringAsync();
|
||||||
}
|
}
|
||||||
|
|
||||||
[Java.Interop.Export("HelpLoginScreen")]
|
[Java.Interop.Export("HelpLoginScreen")]
|
||||||
|
@ -51,6 +51,7 @@
|
|||||||
<Reference Include="Mono.Android.Export" />
|
<Reference Include="Mono.Android.Export" />
|
||||||
<Reference Include="System" />
|
<Reference Include="System" />
|
||||||
<Reference Include="System.Core" />
|
<Reference Include="System.Core" />
|
||||||
|
<Reference Include="System.Net.Http" />
|
||||||
<Reference Include="System.Xml.Linq" />
|
<Reference Include="System.Xml.Linq" />
|
||||||
<Reference Include="System.Xml" />
|
<Reference Include="System.Xml" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
Loading…
Reference in New Issue
Block a user