Skip to content

Instantly share code, notes, and snippets.

@icebeam7
Created October 22, 2018 22:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save icebeam7/a3f60a1d97f88c10ca2220815246dc8d to your computer and use it in GitHub Desktop.
Save icebeam7/a3f60a1d97f88c10ca2220815246dc8d to your computer and use it in GitHub Desktop.
MyStore.EmployeesApp: LoginPage.cs
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