3cx Tapi Server
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user