Example #1
0
        private async Task <OrderItemModelItem> CreateOrderItemsAsync(CartModelItem model)
        {
            var paymentId = await GetPaymentIdAsync(model.TransactionId);

            var orderId = await GetOrderIdAsync(paymentId);

            var response = new OrderItemModelItem();
            var items    = new List <OrderItem>();

            foreach (var item in model.OrderItems)
            {
                var orderItem = OrderItemMapper.MapModelToEntity(item);
                orderItem.OrderId = orderId;
                items.Add(orderItem);
            }
            var result = await _orderItemRepository.CreateRangeAsync(items);

            if (!result)
            {
                response.Errors.Add(ErrorConstants.ImpossibleToCreateOrderItem);
            }
            response.OrderId = orderId;
            return(response);
        }