NonInventPurchasingSystem/CPRNIMS.WebApi/Controllers/SMTP/SMTPMgmtController.cs
2026-01-20 07:44:30 +08:00

71 lines
2.2 KiB
C#

using CPRNIMS.Domain.Contracts.SMTP;
using CPRNIMS.Domain.Services;
using CPRNIMS.Infrastructure.Dto.SMTP;
using CPRNIMS.WebApi.Controllers.Base;
using Microsoft.AspNetCore.Mvc;
namespace CPRNIMS.WebApi.Controllers.SMTP
{
[Security.AuthorizeRoles("SMTPMgmt")]
public class SMTPMgmtController : BaseController
{
private readonly ISMTP _sMTP;
public SMTPMgmtController(ErrorMessageService errorMessageService,
IWebHostEnvironment webHostEnvironment, IConfiguration configuration
, ISMTP sMTP)
: base(errorMessageService, webHostEnvironment, 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;
}
}
}
}