public void Authenticate() { var status_messages = new Dictionary <AuthStatus, string>(); status_messages.Add(AuthStatus.AccountValidated, "Account validated successfully."); status_messages.Add(AuthStatus.UserNotFound, "Username not found."); status_messages.Add(AuthStatus.IncorrectPasswd, "Incorrect password."); AuthStatus status; var userAccount = userAccountsManager.Find(uiService.GetUIField("Username").Value); if (userAccount == null) { status = AuthStatus.UserNotFound; } else if (userAccount.Passwd != uiService.GetUIField("Password").Value) { status = AuthStatus.IncorrectPasswd; } else { status = AuthStatus.AccountValidated; } if (status == AuthStatus.AccountValidated) { this.result = ServiceExecutionResult.Success; } else { remainingAttempts--; if (remainingAttempts == 0) { this.result = ServiceExecutionResult.Failure; } } uiService.BreakLine(); uiService.OutputInfo(status_messages[status], InfoCategory.FixedResponse); if (this.result != ServiceExecutionResult.Undefined) { this.status = ServiceExecutionStatus.Completed; } }