Last active
February 7, 2021 10:33
-
-
Save AbubakarSiddiq/0cb18629e523398d1084ce480fcb75f7 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 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