예제 #1
0
        public async Task <Domain.Orders.Order> Insert(Domain.Orders.Order order)
        {
            if (order == null)
            {
                throw new ArgumentNullException(nameof(order));
            }

            var dbOrder = order.ToDalOrNull(OrderConverter.ToDalNew);

            await _orders.AddAsync(dbOrder);

            await context.SaveChangesAsync();

            return(dbOrder.ToDomainOrNull(OrderConverter.ToDomain));
        }
예제 #2
0
        public async Task <Domain.Orders.Order> InserOrderItem(Domain.Orders.Order order, Domain.OrderItems.OrderItem item)
        {
            if (order == null)
            {
                throw new ArgumentNullException(nameof(order));
            }

            if (item == null)
            {
                throw new ArgumentNullException(nameof(item));
            }

            var dbOrderItem = item.ToDalOrNull(OrderItems.DbEntites.OrderItemConverter.ToDalNew);

            var dbOrder = order.ToDalOrNull(OrderConverter.ToDal);

            dbOrder.Items.Add(dbOrderItem);

            await context.SaveChangesAsync();

            return(dbOrder.ToDomainOrNull(OrderConverter.ToDomain));
        }