public async Task CreateOrderAsync(int basketId, Address Address) { var basket = await _basketRepository.GetByIdAsync(basketId); var items = new List <OrderedItem>(); foreach (var item in basket.Items) { var catalogItem = await _goodsRepository.GetByIdAsync(item.GoodsId); var itemOrdered = new PreOrderedItem(catalogItem.Id, catalogItem.Name, catalogItem.PictureUri); var orderItem = new OrderedItem(itemOrdered, item.UnitPrice, item.Quantity); items.Add(orderItem); } var order = new Order(basket.PurchaserId, Address, items); await _orderRepository.AddAsync(order); }
public OrderedItem(PreOrderedItem item, decimal unitPrice, int units) { Item = item; UnitPrice = unitPrice; Units = units; }