Skip to content

Instantly share code, notes, and snippets.

@dcomartin
Created October 16, 2024 21:30
Show Gist options
  • Save dcomartin/e96dd82e8dc20a8dc835deb2e220f8dd to your computer and use it in GitHub Desktop.
Save dcomartin/e96dd82e8dc20a8dc835deb2e220f8dd to your computer and use it in GitHub Desktop.
public async Task<Option<OrderViewModel>> Handle(GetOrderDetails request, CancellationToken cancellationToken)
{
var order = await _orderRepository.GetByIdAsync(request.OrderId, cancellationToken);
if (order == null)
{
return Option.None<OrderViewModel>();
}
var result = new OrderViewModel
{
OrderDate = order.OrderDate,
OrderItems = order.OrderItems.Select(oi => new OrderItemViewModel
{
PictureUrl = oi.ItemOrdered.PictureUri,
ProductId = oi.ItemOrdered.CatalogItemId,
ProductName = oi.ItemOrdered.ProductName,
UnitPrice = oi.UnitPrice,
Units = oi.Units
}).ToList(),
OrderNumber = order.Id,
ShippingAddress = order.ShipToAddress,
Total = order.Total()
};
return result.Some();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment