async partial void Login_Clicked(UIButton sender) { string serverUri = this.Server.Text; string userName = this.Username.Text; string passWord = this.Password.Text; if (string.IsNullOrEmpty(serverUri) || string.IsNullOrWhiteSpace(serverUri)) { this.ShowAlert(InvalidUriTitle, EmptyUriMessage); return; } try { this.LoginActivityIndicator.Hidden = false; this.LoginActivityIndicator.StartAnimating(); sender.Enabled = false; var serverSettings = new ServerSettings(serverUri, userName, passWord); await SessionFactory.CheckConnectionAsync(serverSettings); var localStorage = new LocalStorage(); localStorage.Clean(); AppGroupSettings.SaveServerSettings(serverSettings); this.ShowAlert(LoginSuccessfulTitle, LoginSuccessfulMessage); } catch (System.Net.WebException ex) { if (ex.Status == System.Net.WebExceptionStatus.NameResolutionFailure) { this.ShowAlert(InvalidUriTitle, IncorrectServerNameMessage); } else { this.ShowAlert(ErrorTitle, ex.Message); } } catch (Exception ex) { this.ShowAlert(ErrorTitle, ex.Message); } finally { sender.Enabled = true; } this.Editing = false; this.Server.ResignFirstResponder(); this.Username.ResignFirstResponder(); this.Password.ResignFirstResponder(); }