private async void DoLogon(CommandExecutionContext context)
{
// validate...
ErrorBucket errors = new ErrorBucket();
Validate(errors);
// ok?
if (!(errors.HasErrors))
{
// get a handler...
ILogonServiceProxy proxy = ServiceProxyFactory.Current.GetHandler<ILogonServiceProxy>();
// call...
using(this.EnterBusy())
{
var result = await proxy.LogonAsync(this.Username, this.Password);
if (!(result.HasErrors))
{
// logon... pass through the username as each user gets their own database...
await StreetFooRuntime.LogonAsync(this.Username, result.Token);
// while we're here - store a setting containing the logon name of the user...
await SettingItem.SetValueAsync(LastUsernameKey, this.Username);
// remember the user?
if (this.RememberMe)
await SettingItem.SetValueAsync(LogonTokenKey, result.Token);
// show the reports page...
this.Host.ShowView(typeof(IReportsPageViewModel));
}
else
errors.CopyFrom(result);
}
}
// errors?
if (errors.HasErrors)
await this.Host.ShowAlertAsync(errors);
}