3cx Tapi Server

This commit is contained in:
2026-03-18 11:27:11 +01:00
parent 7a99b1ab55
commit fe8fcdf45b
12 changed files with 363 additions and 0 deletions
@@ -0,0 +1,43 @@
using System.Collections.Generic;
using System.Threading.Tasks;
using CPATapi.Server.Models;
using Dapper;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Data.SqlClient;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Logging;
namespace CPATapi.Server.Controllers
{
[ApiController]
[Route("[controller]")]
public class ContactController : ControllerBase
{
private readonly ILogger<ContactController> _logger;
private readonly IConfiguration _config;
public ContactController(ILogger<ContactController> logger, IConfiguration config)
{
_logger = logger;
_config = config;
}
[HttpGet]
public async Task<IEnumerable<TapiContact>> GetAsync()
{
await using var con = new SqlConnection(_config["Db:ConnectionString"]);
await con.OpenAsync();
var contacts = await con.QueryAsync<TapiContact>(@"
SELECT
TD_ID,
TD_NAME,
TD_NUMBER,
TD_NUMBER_TAPI,
TD_MEDIUM
FROM dbo.CP_TAPI_DIRECTORY");
return contacts;
}
}
}