public Order Create(CreateOrderCommand command, string email)
        {
            var user = _userRepository.GetByEmail(email);
            var orderItems = new List<OrderItem>();
            foreach (var item in command.OrderItems)
            {
                var orderItem = new OrderItem();
                var product = _productRepository.Get(item.Product);
                orderItem.AddProduct(product, item.Quantity, item.Price);
                orderItems.Add(orderItem);
            }

            var order = new Order(orderItems, user.Id);
            order.Place();
            _orderRepository.Create(order);

            if (Commit())
                return order;

            return null;
        }
Ejemplo n.º 2
0
 public void Update(Order order)
 {
     _context.Entry<Order>(order).State = System.Data.Entity.EntityState.Modified;
 }
Ejemplo n.º 3
0
 public void Create(Order order)
 {
     _context.Orders.Add(order);
 }