Files
PostManCloneApp/PostmanCloneUI/Dashboard.cs

40 lines
848 B
C#

using PostmanCloneLibrary;
namespace PostmanCloneUI;
public partial class Dashboard : Form
{
private readonly ApiAccess _apiAccess = new();
public Dashboard()
{
InitializeComponent();
}
private async void callApi_Click(object sender, EventArgs e)
{
systemStatus.Text = "Calling API...";
resultsText.Text = "";
// Validate the API URL
if (_apiAccess.IsValidUrl(apiText.Text) == false)
{
systemStatus.Text = "Invalid URL...";
return;
}
try
{
resultsText.Text = await _apiAccess.CallApiAsync(apiText.Text);
systemStatus.Text = "Ready";
}
catch (Exception ex)
{
resultsText.Text = "Error: " + ex.Message;
systemStatus.Text = "Error";
}
}
}