public static Order ToModel(this UpdateOrderTotalCommand command) { var result = new Order { Id = command.Id, CustomerId = command.CustomerId, OrderNumber = command.OrderNumber, Total = command.Total, CreatedDate = DateTime.Now, Status = Enum.TryParse(command.Status, out OrderStatus orderStatus) ? orderStatus : 0 }; return(result); }
public async Task <IActionResult> UpdateOrderTotal([FromRoute] int id, [FromRoute] decimal total, [FromBody] UpdateOrderTotalCommand command) { if (id != command.Id) { return(BadRequest()); } command.Total = total; var result = await _mediator.Send(command); return(Ok(result)); }