Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save AbubakarSiddiq/0cb18629e523398d1084ce480fcb75f7 to your computer and use it in GitHub Desktop.
Save AbubakarSiddiq/0cb18629e523398d1084ce480fcb75f7 to your computer and use it in GitHub Desktop.
using MassTransit;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Shared.Models.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
namespace Customer.Microservcie.Controllers
{
[Route("api/[controller]")]
[ApiController]
public class CustomerOrderController : ControllerBase
{
private readonly IBus _busService;
public CustomerOrderController(IBus busService)
{
_busService = busService;
}
[HttpPost]
public async Task<string> CreateOrder(CustomerOrder order)
{
if (order != null)
{
order.OrderDate = DateTime.Now;
Uri uri = new Uri("rabbitmq://localhost/orderQueue");
var endPoint = await _busService.GetSendEndpoint(uri);
await endPoint.Send(order);
return "true";
}
return "false";
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment