private OrderLine(OrderLineId id, Order order, OrderItem orderItem) { Id = id; OrderId = order.Id; Order = order; OrderItem = orderItem; }
public async Task <IActionResult> Get([FromRoute] Guid orderId, [FromRoute] Guid id) { var orderLineIdValue = OrderLineId.With(id).Value; var orderLine = await _processor.ProcessAsync(new ReadModelByIdQuery <OrderLineReadModel>(orderLineIdValue), new CancellationToken()); return(Ok(orderLine)); }
public async Task <IActionResult> Post([FromRoute] Guid orderId, [FromBody] OrderLineWrite value) { var orderIdKey = OrderId.With(orderId); var orderLineId = OrderLineId.NewComb(); var orderLine = new OrderLine(orderLineId, ProductId.NewComb(), value.Title, value.Price, value.Amount); var cmd = new AddOrderLine(orderIdKey, orderLine); await this._commandBus.PublishAsync(cmd, new CancellationToken()).ConfigureAwait(false); return(CreatedAtAction("Get", new { orderId = orderIdKey.Value, id = orderLineId.Value }, null)); }
public async Task <IActionResult> Get([FromRoute] Guid orderId) { var orderIdValue = OrderId.With(orderId).Value; var domainResults = await _processor.ProcessAsync(new GetOrderLinesByOrderIdQuery(orderIdValue), new CancellationToken()); var results = domainResults.Select(x => new OrderLineRead { Id = OrderLineId.With(x.Id).GetGuid(), ProductId = ProductId.With(x.ProductId).GetGuid(), Title = x.Title, Price = x.Price, Amount = x.Amount }).ToList(); return(Ok(results)); }