implemented rabbitmq
This commit is contained in:
1 parent
7384cfcc84
commit
bc38afcbf8
5 files changed
+50
-4
No files matched your search
@@ -2,14 +2,16 @@ using Microsoft.AspNetCore.Mvc;
|
||||
using api.Services;
|
||||
using api.DTOs;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using api.RabbitMQ;
|
||||
|
||||
namespace api.Controllers
|
||||
{
|
||||
[ApiController]
|
||||
[Route("api/[controller]")]
|
||||
public class PersonController(IPersonService personService) : ControllerBase
|
||||
public class PersonController(IPersonService personService, IMessageProducer messagePublisher) : ControllerBase
|
||||
{
|
||||
private readonly IPersonService _personService = personService;
|
||||
private readonly IMessageProducer _messagePublisher = messagePublisher;
|
||||
|
||||
[HttpGet]
|
||||
public async Task<IActionResult> GetAll()
|
||||
@@ -37,9 +39,9 @@ namespace api.Controllers
|
||||
{
|
||||
try
|
||||
{
|
||||
await _personService.AddPersonAsync(personDto);
|
||||
return CreatedAtAction(nameof(GetByUsername), new { username = personDto.Username }, personDto);
|
||||
|
||||
await _personService.AddPersonAsync(personDto);
|
||||
_messagePublisher.SendMessage<PersonDto>(personDto);
|
||||
return CreatedAtAction(nameof(GetByUsername), new { username = personDto.Username }, personDto);
|
||||
}
|
||||
catch (ArgumentException ex)
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user