Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update controllers #56

Merged
merged 9 commits into from
Apr 2, 2024
Prev Previous commit
Next Next commit
Added MailController
SharifovDeveloper committed Apr 2, 2024
commit 4efad19fca0443f68b2b95f6e4af7d74e84adbad
30 changes: 30 additions & 0 deletions Inflow.Api/Controllers/MailController.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
using Inflow.Api.Constants;
using Inflow.Domain.Intefaces.Services;
using Microsoft.AspNetCore.Mvc;

namespace Inflow.Api.Controllers
{
[Route("api/mail")]
[ApiController]
public class MailController : Controller
{
private readonly IEmailSender _emailSender;

public MailController() { }
public MailController(IEmailSender emailSender)
{
_emailSender = emailSender ?? throw new ArgumentNullException(nameof(emailSender));
}

[HttpPost("register")]
public async Task<ActionResult> SendRegisterEmail(string receiverEmail, string? name)
{
string subject = EmailConfigurations.Subject;
string emailBody = EmailConfigurations.RegisterBody.Replace("{recipientName}", name);

await _emailSender.SendEmail(receiverEmail, subject, emailBody);

return Ok();
}
}
}