public async Task <IActionResult> Index() { return(View( new HomeViewModel { Whoami = await Whoami.Get(), })); }
private void buttonApiTest_Click(object sender, EventArgs e) { int apiPort = apiDefaultApiPort; if (int.TryParse(textPort.Text, out apiPort)) { _migrate.Plan.Destination.ApiPort = int.Parse(textPort.Text); } else { _migrate.Plan.Destination.ApiPort = apiDefaultApiPort; } _migrate.Plan.Destination.ApiHost = textHost.Text; _migrate.Plan.Destination.ApiKey = textboxApiKey.Text; _migrate.Plan.Destination.UseHttps = checkBoxHttps.Checked; if (String.IsNullOrEmpty(_migrate.Plan.Destination.ApiKey)) { MessageBox.Show("API Key cannot be null", "", MessageBoxButtons.OK, MessageBoxIcon.Error); textboxApiKey.Focus(); return; } if (String.IsNullOrEmpty(_migrate.Plan.Destination.ApiHost)) { MessageBox.Show("API Host cannot be null", "", MessageBoxButtons.OK, MessageBoxIcon.Error); textHost.Focus(); return; } _migrate.Api = new ApiClient(_migrate.Plan.Destination.ApiKey, _migrate.Plan.Destination.ApiHost, _migrate.Plan.Destination.ApiPort, _migrate.Plan.Destination.UseHttps, defaultApiFormat, apiSuppressStatusCode); try { var WhoApiResult = _migrate.Api.Whoami(); if (WhoApiResult.ErrorCode != 0) { MessageBox.Show(String.Format("{0}\nResponse Code: {1}\nError Code: {2}", WhoApiResult.Message, WhoApiResult.StatusCode, WhoApiResult.ErrorCode), "MaestroPanel", MessageBoxButtons.OK, MessageBoxIcon.Error); ApiConnectionTest = false; } else { currentPanelUser = WhoApiResult.Details; MessageBox.Show(String.Format("Connected Successful. \n\r Username: {0}", currentPanelUser.Username), "API Test", MessageBoxButtons.OK, MessageBoxIcon.Information); ApiConnectionTest = true; } } catch (Exception ex) { MessageBox.Show(String.Format(ex.Message), "API Test", MessageBoxButtons.OK, MessageBoxIcon.Error); ApiConnectionTest = false; } }