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 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 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 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; } } } }