private async void DoRegistration(CommandExecutionContext context) { // if we don't have a context, create one... if (context == null) { context = new CommandExecutionContext(); } // validate... ErrorBucket errors = new ErrorBucket(); Validate(errors); // ok? if (!(errors.HasErrors)) { // get a handler... var proxy = TinyIoCContainer.Current.Resolve <IRegisterServiceProxy>(); // call... using (this.EnterBusy()) { var result = await proxy.RegisterAsync(this.Username, this.Email, this.Password, this.Confirm); // ok? if (!(result.HasErrors)) { // show a message to say that a user has been created... (this isn't a helpful message, // included for illustration...) await this.Host.ShowAlertAsync(string.Format("The new user has been created.\r\n\r\nUser ID: {0}", result.UserId)); // save the username as the last used... await SettingItem.SetValueAsync(LogonPageViewModel.LastUsernameKey, this.Username); // show the reports page... this.Host.ShowView(typeof(ILogonPageViewModel)); } else { errors.CopyFrom(result); } } } // errors? if (errors.HasErrors) { await this.Host.ShowAlertAsync(errors); } }
private async void DoLogon(CommandExecutionContext context) { // validate... ErrorBucket errors = new ErrorBucket(); Validate(errors); // ok? if (!(errors.HasErrors)) { // get a handler... var proxy = TinyIoCContainer.Current.Resolve <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); } }
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); // show the reports page... this.Host.ShowView(typeof(IReportsPageViewModel)); } else errors.CopyFrom(result); } } // errors? if (errors.HasErrors) await this.Host.ShowAlertAsync(errors); }
private async void DoRegistration(CommandExecutionContext context) { // if we don't have a context, create one... if (context == null) context = new CommandExecutionContext(); // validate... ErrorBucket errors = new ErrorBucket(); Validate(errors); // ok? if (!(errors.HasErrors)) { // get a handler... var proxy = TinyIoCContainer.Current.Resolve<IRegisterServiceProxy>(); // call... using (this.EnterBusy()) { var result = await proxy.RegisterAsync(this.Username, this.Email, this.Password, this.Confirm); // ok? if (!(result.HasErrors)) { // show a message to say that a user has been created... (this isn't a helpful message, // included for illustration...) await this.Host.ShowAlertAsync(string.Format("The new user has been created.\r\n\r\nUser ID: {0}", result.UserId)); // save the username as the last used... await SettingItem.SetValueAsync(LogonPageViewModel.LastUsernameKey, this.Username); // show the reports page... this.Host.ShowView(typeof(ILogonPageViewModel)); } else errors.CopyFrom(result); } } // errors? if(errors.HasErrors) await this.Host.ShowAlertAsync(errors); }