Last works ...
This commit is contained in:
@@ -0,0 +1,81 @@
|
||||
using xApi.Interfaces;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace xApi.Controllers
|
||||
{
|
||||
[ApiController]
|
||||
[ApiVersion("1.0")]
|
||||
[Route("api/v{version:apiVersion}/[controller]")]
|
||||
public class AzureController : ControllerBase
|
||||
{
|
||||
//
|
||||
private readonly IAzureServices azureServices;
|
||||
private readonly ILogger<AzureController> logger;
|
||||
|
||||
public AzureController(
|
||||
IAzureServices azureServices,
|
||||
ILogger<AzureController> logger
|
||||
)
|
||||
{
|
||||
//
|
||||
this.logger = logger;
|
||||
this.azureServices = azureServices;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get connection data from Azure Services ...
|
||||
/// </summary>
|
||||
/// <param name="cancellationToken"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet("ConnectionData")]
|
||||
public async Task<ActionResult<string>> GetConnectionData(
|
||||
CancellationToken cancellationToken = default
|
||||
)
|
||||
{
|
||||
//
|
||||
try
|
||||
{
|
||||
//
|
||||
var response = await azureServices
|
||||
.GetConnectionDataAsync(cancellationToken);
|
||||
|
||||
//
|
||||
return Ok(response);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
//
|
||||
logger.LogError(ex, "Error occurred ...");
|
||||
return StatusCode(500, "Internal server error");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get projects from Azure Services ...
|
||||
/// </summary>
|
||||
/// <param name="cancellationToken"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet("GetProjects")]
|
||||
public async Task<ActionResult<string>> GetProjects(
|
||||
CancellationToken cancellationToken = default
|
||||
)
|
||||
{
|
||||
//
|
||||
try
|
||||
{
|
||||
//
|
||||
var response = await azureServices
|
||||
.GetProjectsAsync(cancellationToken);
|
||||
|
||||
//
|
||||
return Ok(response);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
//
|
||||
logger.LogError(ex, "Error occurred ...");
|
||||
return StatusCode(500, "Internal server error");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user