Skip to content

Instantly share code, notes, and snippets.

@alikrc
Created April 22, 2022 12:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alikrc/ccd49133e70359e88d559e40c0ead433 to your computer and use it in GitHub Desktop.
Save alikrc/ccd49133e70359e88d559e40c0ead433 to your computer and use it in GitHub Desktop.
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