74 lines
2.3 KiB
C#
74 lines
2.3 KiB
C#
using CPRNIMS.Domain.Contracts.SMTP;
|
|
using CPRNIMS.Domain.Services;
|
|
using CPRNIMS.Infrastructure.Dto.SMTP;
|
|
using CPRNIMS.Infrastructure.Helper;
|
|
using CPRNIMS.WebApi.Controllers.Base;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
|
|
namespace CPRNIMS.WebApi.Controllers.SMTP
|
|
{
|
|
[Security.AuthorizeRoles("SMTPMgmt")]
|
|
[Route("api/[controller]")]
|
|
[ApiController]
|
|
public class SMTPMgmtController : BaseController
|
|
{
|
|
private readonly ISMTP _sMTP;
|
|
public SMTPMgmtController(ErrorMessageService errorMessageService,
|
|
IWebHostEnvironment webHostEnvironment, SMTPHelper sMTPHelper,
|
|
IConfiguration configuration, ISMTP sMTP) :
|
|
base(errorMessageService, webHostEnvironment, sMTPHelper, configuration)
|
|
{
|
|
_sMTP = sMTP;
|
|
}
|
|
[HttpPost("GetMySmtp")]
|
|
public async Task<IActionResult> GetMySmtp(SMTPCredentialDto itemCodeDto)
|
|
{
|
|
try
|
|
{
|
|
var allPR = await _sMTP.GetMySmtp(itemCodeDto);
|
|
|
|
return Ok(allPR);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
var message = ex.InnerException?.ToString() ?? ex.Message.ToString();
|
|
await PostErrorMessage(message, "WebApi");
|
|
throw;
|
|
}
|
|
}
|
|
[HttpPost("GetAllSmtp")]
|
|
public async Task<IActionResult> GetAllSmtp(SMTPCredentialDto itemCodeDto)
|
|
{
|
|
try
|
|
{
|
|
var allPR = await _sMTP.GetAllSmtp(itemCodeDto);
|
|
|
|
return Ok(allPR);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
var message = ex.InnerException?.ToString() ?? ex.Message.ToString();
|
|
await PostErrorMessage(message, "WebApi");
|
|
throw;
|
|
}
|
|
}
|
|
|
|
[HttpPost("PostPutSmtp")]
|
|
public async Task<IActionResult> PostPutSmtp(SMTPCredentialDto SMTPCredentialDto)
|
|
{
|
|
try
|
|
{
|
|
var pR = await _sMTP.PostPutSmtp(SMTPCredentialDto);
|
|
|
|
return Ok(pR);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
var message = ex.InnerException?.ToString() ?? ex.Message.ToString();
|
|
await PostErrorMessage(message, "WebApi");
|
|
throw;
|
|
}
|
|
}
|
|
}
|
|
}
|