public async Task CreateOrderItem(Order order) { var id = order.Id; var items = order.Items.ToList(); foreach (var item in items) { item.OrderId = id; item.Status = GlobalConstants.Sent; item.Product = null; } await orderItemRepository.AddRangeAsync(items); await orderItemRepository.SaveChangesAsync(); }