protected override async Task <GetOrderDto> ExecuteAsync(CompleteOrderCommand request, CancellationToken ct) { CompleteOrderDto orderDto = _mapper.Map <CompleteOrderDto>(request); var result = await _orderService.CompleteAsync(orderDto, ct); var orderCompletedMessage = new OrderCompletedMessage(result.Id, request.AccountId, result.Games.Select(t => t.Id).ToList()); await _serviceBusClient.PublishOrderCompletedAsync(orderCompletedMessage); return(result); }
public HttpResponseMessage CompleteOrder(CompleteOrderDto completeOrderDto) { var orderRepository = new OrderRepository(); var paid = orderRepository.MarkAsPaid(completeOrderDto); if (paid) { return(Request.CreateResponse(HttpStatusCode.OK, "Order has been completed")); } return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, "It's not you, it's me - order not copmlete")); }
public bool MarkAsPaid(CompleteOrderDto completeOrderDto) { using (var db = CreateConnection()) { db.Open(); var query = @"UPDATE [dbo].[Orders] SET [PaymentTypeId] = @PaymentTypeId WHERE OrderId = @OrderId"; var queryVariables = new { completeOrderDto.PaymentTypeId, completeOrderDto.OrderId }; var markAsPaid = db.Execute(query, queryVariables); return(markAsPaid == 1); } }
public async Task <GetOrderDto> CompleteAsync(CompleteOrderDto order, CancellationToken ct = default) { _logger.LogInformation("Complete current order for account={AccountId}", order.AccountId); OrderBase currentOrder = await _unitOfWork.OrderRepository.GetCurrentOrderAsync(order.AccountId, ct); ValidateCompletedOrder(currentOrder, order.AccountId); currentOrder.CompleteOrder(); _unitOfWork.OrderRepository.Update(currentOrder); await _unitOfWork.SaveAsync(ct); return(_mapper.Map <GetOrderDto>(currentOrder)); }
public async Task <IActionResult> CreateOrder(CompleteOrderDto completeOrderDto) { }