public async Task <IActionResult> AddOrder([FromBody] OrderModel order) { var command = new OrderCreateCommand(order.OrderItems, order.UserId, order.UserName, order.City, order.Street, order.Country, order.ZipCode, order.CardNumber, order.CardHolderName, order.CardExpiration, order.CardTypeId); var result = await _mediator.Send(command); return(Ok(result)); }
public async Task CreateAsync(OrderCreateCommand command) { var content = new StringContent( JsonSerializer.Serialize(command), Encoding.UTF8, "application/json" ); var request = await httpClient.PostAsync($"{apiGatewayUrl}api/orders", content); request.EnsureSuccessStatusCode(); }
public async Task <IActionResult> Create([FromBody] NewOrder newOrder) { var command = new OrderCreateCommand(newOrder); var result = await this._mediator.Send(command); if (result.Status == CommandResultStatus.Success) { return(new CreatedResult("", "")); } return(new BadRequestResult()); }
public void CreateOrder_ErrorDetail() { var service = this.ServiceProvider.GetService <IRequestHandler <OrderCreateCommand, CommandResponse> >(); var command = new OrderCreateCommand() { CustumerId = Guid.Parse("1f1aa443-373f-44a6-bbe6-002fcbaffb4e"), Details = new OrderDetailCommand[0] }; var result = service.Handle(command, new System.Threading.CancellationToken()).Result; Assert.IsFalse(result.IsValid); Console.WriteLine(string.Join(Environment.NewLine, result.Errors.Select(e => e.ErrorMessage))); }
public async Task <ICommandBase> UpdateOrder(OrderCreateCommand order) { var _order = new Order { Id = order.OrderId, Name = order.OrderName, SupplierId = order.SupplierId }; var result = await orderRepository.UpdateOrder(_order); await orderItemRepository.UpdateOrdertem(order.ItemsId, _order.Id); return(result); }
async Task <CommandResponse> IOrderApplication.Create(OrderModel order) { //existe um cara que chama mapper,utilizado para mapear de uma classe para outra, não utilizei aqui para não complicar, mas aconselho usar nos projetos var orderCommand = new OrderCreateCommand() { OrderId = order.OrderId, CustumerId = order.CustumerId, Date = order.Date, Details = order.Details.Select(d => new Sales.Commands.OrdersCreate.OrderDetailCommand() { ProductId = d.ProductId, Quantity = d.Quantity }) }; return(await this._mediatorHandler.SendCommand(orderCommand)); }
public async Task Consume(ConsumeContext <UserCheckoutAccepted> context) { var result = false; var eventMsg = context.Message; if (eventMsg.RequestId != Guid.Empty) { // 创建订单指令 var createOrderCommand = new OrderCreateCommand(eventMsg.Basket.Items, eventMsg.UserId, eventMsg.UserName, eventMsg.City, eventMsg.Street, eventMsg.State, eventMsg.Country, eventMsg.ZipCode, eventMsg.CardNumber, eventMsg.CardHolderName, eventMsg.CardExpiration, eventMsg.CardSecurityNumber, eventMsg.CardTypeId); // 请求创建订单 var requestCreateOrder = new IdentifiedCommand <OrderCreateCommand, bool>(eventMsg.RequestId, createOrderCommand); result = await _mediator.Send(requestCreateOrder); } _logger.LogTrace(result ? $"UserCheckoutAccepted integration event has been received and a create new order process is started with requestId: {eventMsg.RequestId}" : $"UserCheckoutAccepted integration event has been received but a new order process has failed with requestId: {eventMsg.RequestId}"); }
public async Task <IActionResult> OnPost([FromBody] OrderCreateCommand command) { await _orderProxy.CreateAsync(command); return(this.StatusCode(200)); }
public async Task <IActionResult> Create(OrderCreateCommand command) { await _handler.Execute(command); return(NoContent()); }
public async Task <IActionResult> Create(OrderCreateCommand notification) { await _mediator.Publish(notification); return(Ok()); }
public async Task <ActionResult <OrderResponse> > OrderCreate([FromBody] OrderCreateCommand command) { var result = await _mediator.Send(command); return(Ok(result)); }
public async Task <IActionResult> Create(OrderCreateCommand command) { await _mediator.Publish(command); return(Ok()); }
public async Task <IActionResult> Create(OrderCreateCommand command) { await _orderProxy.CreateAsync(command); return(Ok()); }
public Task CreateOrder([FromBody] OrderCreateCommand orderCreateCommand, CancellationToken cancellationToken) { return(mediator.Send(orderCreateCommand, cancellationToken)); }
public async Task <IActionResult> Post([FromBody] OrderCreateCommand command) { var id = await _mediator.Send(command); return(await Get(id)); }