public void RaiseFailure(object sender, ErrorBucket errors) { if (this.Failure != null) { this.Failure(sender, errors); } }
private void Validate(ErrorBucket errors) { // do basic data presence validation... if (string.IsNullOrEmpty(Username)) { errors.AddError("Username is required."); } if (string.IsNullOrEmpty(Email)) { errors.AddError("Email is required."); } if (string.IsNullOrEmpty(Password)) { errors.AddError("Password is required."); } if (string.IsNullOrEmpty(Confirm)) { errors.AddError("Confirm password is required."); } // check the passwords... if (!(string.IsNullOrEmpty(Password)) && this.Password != this.Confirm) { errors.AddError("The passwords do not match."); } }
public void CopyFrom(ErrorBucket donor) { // copy the normal errors... this.Errors.Clear(); this.Errors.AddRange(donor.Errors); // copy the fatal error... this.Fatal = donor.Fatal; }
private void Validate(ErrorBucket errors) { // do basic data presence validation... if (string.IsNullOrEmpty(Username)) { errors.AddError("Username is required."); } if (string.IsNullOrEmpty(Password)) { errors.AddError("Password is required."); } }
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); } }
public static Task ChainFailureHandler(this Task task, FailureHandler failure, Action complete = null) { // create a handler that will raise an exception if an operation fails... return(task.ContinueWith((t) => { // create a fatal error bucket... ErrorBucket fatal = ErrorBucket.CreateFatalBucket(t.Exception); failure(task, fatal); // completed? if (complete != null) { complete(); } }, TaskContinuationOptions.OnlyOnFaulted)); }
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 void DoRegistration() { // validate... ErrorBucket errors = new ErrorBucket(); Validate(errors); // ok? if (!(errors.HasErrors)) { // the real call to the server will return an ID here - we'll fake it for now... string userId = Guid.NewGuid().ToString(); // call the success handler... this.Host.ShowAlertAsync(string.Format("Created user: {0}", userId)); } // errors? if(errors.HasErrors) 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); // 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 void DoRegistration() { // validate... ErrorBucket errors = new ErrorBucket(); Validate(errors); // ok? if (!(errors.HasErrors)) { // the real call to the server will return an ID here - we'll fake it for now... string userId = Guid.NewGuid().ToString(); // call the success handler... this.Host.ShowAlertAsync(string.Format("Created user: {0}", userId)); } // errors? if (errors.HasErrors) { this.Host.ShowAlertAsync(errors); } }
protected override Task <ErrorBucket> ValidateAsync() { var bucket = new ErrorBucket(); if (string.IsNullOrEmpty(this.Item.Title)) { bucket.AddError("Title is required."); } if (string.IsNullOrEmpty(this.Item.Description)) { bucket.AddError("Description is required."); } if (!(this.HasImage)) { bucket.AddError("An image is required."); } if (this.Item.Latitude == 0 && this.Item.Longitude == 0) { bucket.AddError("A position is required."); } // return... return(Task.FromResult <ErrorBucket>(bucket)); }
public IAsyncOperation<IUICommand> ShowAlertAsync(ErrorBucket errors) { return null; }
internal GetReportImageResult(ErrorBucket errors) : base(errors) { }
public CreateResult(ErrorBucket bucket) : base(bucket) { }
// special constructor for cloning another error bucket... protected ErrorBucket(ErrorBucket donor) : this() { CopyFrom(donor); }
internal GetReportsByUserResult(ErrorBucket bucket) : base(bucket) { }
internal LogonResult(ErrorBucket bucket) : base(bucket) { }
public Task ShowAlertAsync(ErrorBucket errors) { return null; }
internal LogonResult(ErrorBucket errors) : base(errors) { }
private void Validate(ErrorBucket errors) { // do basic data presence validation... if (string.IsNullOrEmpty(Username)) errors.AddError("Username is required."); if (string.IsNullOrEmpty(Password)) errors.AddError("Password is required."); }
internal RegisterResult(ErrorBucket bucket) : base(bucket) { }
internal CreateReportResult(ErrorBucket bucket) : base(bucket) { }
public Task ShowAlertAsync(ErrorBucket errors) { return(null); }
public RegisterResult(ErrorBucket bucket) : base(bucket) { }
private void Validate(ErrorBucket errors) { // do basic data presence validation... if (string.IsNullOrEmpty(Username)) errors.AddError("Username is required."); if (string.IsNullOrEmpty(Email)) errors.AddError("Email is required."); if (string.IsNullOrEmpty(Password)) errors.AddError("Password is required."); if (string.IsNullOrEmpty(Confirm)) errors.AddError("Confirm password is required."); // check the passwords... if (!(string.IsNullOrEmpty(Password)) && this.Password != this.Confirm) errors.AddError("The passwords do not match."); }
public IAsyncOperation<Windows.UI.Popups.IUICommand> ShowAlertAsync(ErrorBucket errors) { return null; }