Created
October 22, 2018 22:40
-
-
Save icebeam7/a3f60a1d97f88c10ca2220815246dc8d to your computer and use it in GitHub Desktop.
MyStore.EmployeesApp: LoginPage.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using Xamarin.Forms; | |
using Xamarin.Forms.Xaml; | |
using MyStore.Services; | |
using MyStore.Models; | |
namespace MyStore.EmployeesApp.Pages | |
{ | |
[XamlCompilation(XamlCompilationOptions.Compile)] | |
public partial class LoginPage : ContentPage | |
{ | |
public LoginPage () | |
{ | |
InitializeComponent (); | |
} | |
public async void SignInButton_Clicked(object sender, EventArgs e) | |
{ | |
var username = UserNameEntry.Text; | |
var password = PasswordEntry.Text; | |
var employee = await StoreWebApiClient.Instance.Login(username, password); | |
if (employee != default(EmployeeDTO)) | |
{ | |
App.CurrentEmployee = employee; | |
await DisplayAlert("Welcome!", $"Welcome {employee.FullName}", "OK"); | |
await Navigation.PushAsync(new CustomerListPage()); | |
} | |
else | |
{ | |
await DisplayAlert("Error!", "Wrong credentials!", "OK"); | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment