Created
April 22, 2022 12:12
-
-
Save alikrc/ccd49133e70359e88d559e40c0ead433 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using MassTransit; | |
using MasstransitDemo.Api.Models; | |
using MasstransitDemo.Shared; | |
using Microsoft.AspNetCore.Mvc; | |
namespace MasstransitDemo.Api.Controllers; | |
[Route("api/[controller]")] | |
[ApiController] | |
public class NotificationController : ControllerBase | |
{ | |
public readonly IPublishEndpoint publishEndpoint; | |
public NotificationController(IPublishEndpoint publishEndpoint) | |
{ | |
this.publishEndpoint = publishEndpoint; | |
} | |
[HttpPost] | |
public async Task<IActionResult> Notify(NotificationDto notificationDto) | |
{ | |
await publishEndpoint.Publish<INotificationCreated>(new { | |
NotificationDate = notificationDto.NotificationDate, | |
NotificationMessage = notificationDto.NotificationMessage, | |
NotificationType = notificationDto.NotificationType | |
}); | |
return Ok(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment