protected async Task ExecuteSubmitCommand() { try { this.progressService.Show(); string errorMessage = string.Empty; if (string.IsNullOrWhiteSpace(this.Email)) { errorMessage = errorMessage + Utility.EAMAILMESSAGE; } else if (!Utility.IsValidEmailAddress(this.Email)) { errorMessage = errorMessage + Utility.INVALIDEMAILMESSAGE; } if (string.IsNullOrWhiteSpace(this.FirstName)) { errorMessage = errorMessage + Utility.FIRSTNAMEMESSAGE; } if (string.IsNullOrWhiteSpace(this.LastName)) { errorMessage = errorMessage + Utility.LASTNAMEMESSAGE; } if (string.IsNullOrWhiteSpace(this.AgencyName)) { errorMessage = errorMessage + Utility.AGENCYMESSAGE; } if (!this.IsChecked) { errorMessage = errorMessage + Utility.TERMSANDCONDITIONMESSAGE; } if (!string.IsNullOrEmpty(errorMessage)) { this.progressService.Dismiss(); MessagingCenter.Send(this, "msg", errorMessage); } else { var x = DependencyService.Get <FormSample.Helpers.Utility.INetworkService>().IsReachable(); if (!x) { this.progressService.Dismiss(); MessagingCenter.Send(this, "msg", Utility.NOINTERNETMESSAGE); } else if (await this.dataService.GetAgent(this.Email) != null) { this.progressService.Dismiss(); MessagingCenter.Send(this, "msg", Utility.EMAILALREADYEXISTMESSAGE); } else { var a = new Agent() { Id = this.Id, Email = this.Email, FirstName = this.FirstName, LastName = this.LastName, Phone = this.Phone, AgencyName = this.AgencyName }; var result = await dataService.AddAgent(a); if (result != null && !string.IsNullOrWhiteSpace(this.Email)) { Settings.GeneralSettings = this.Email; this.AddAgentToLocalDatabase(result); await uploadService.UpdatePaytableDataFromService(); } ilm.ShowMainPage(); } } } catch (Exception) { progressService.Dismiss(); MessagingCenter.Send(this, "msg", Utility.SERVERERRORMESSAGE); } }
protected async Task ExecuteSubmitCommand() { try { bool isValid = true; string errorMessage = string.Empty; if (string.IsNullOrWhiteSpace(this.Email)) { errorMessage = errorMessage + "Email is required.\n"; } else if (!Utility.IsValidEmailAddress(this.Email)) { errorMessage = errorMessage + "Please enter valid email address.\n"; } if (string.IsNullOrWhiteSpace(this.FirstName)) { errorMessage = errorMessage + "Firstname is required.\n"; } if (string.IsNullOrWhiteSpace(this.LastName)) { errorMessage = errorMessage + "Lastname is required.\n"; } if (string.IsNullOrWhiteSpace(this.AgencyName)) { errorMessage = errorMessage + "Agency name is required.\n"; } // if (!this.IsChecked) // { // errorMessage = errorMessage + "terms & condition must be checked."; // } if (!string.IsNullOrEmpty(errorMessage)) { isValid = false; MessagingCenter.Send(this, "msg", errorMessage); } else { if (await this.dataService.GetAgent(this.Email) != null) { MessagingCenter.Send(this, "msg", "Email already exist."); } else { var a = new Agent() { Id = this.Id, Email = this.Email, FirstName = this.FirstName, LastName = this.LastName, Phone = this.Phone, AgencyName = this.AgencyName }; var result = await dataService.AddAgent(a); if (result != null && !string.IsNullOrWhiteSpace(this.Email)) { this.CreateDatabase(result); Settings.GeneralSettings = this.Email; } await navigation.PopAsync(); } } } catch (Exception ex) { } //if (await this.dataService.IsValidUser(this.Username, this.Password)) //{ //} }