Exemplo n.º 1
0
        public static Order Create(Guid customerId)
        {
            var session = SessionFactory.GetCurrentSession();

            var date = DateTime.Now;
            var order = new Order(Guid.NewGuid(), customerId, date);
            order.CreatedBy = session.Name;
            order.Created = date;
            order.SetSystemFields(0, order.CreatedBy, order.Created);
            return order;
        }
Exemplo n.º 2
0
        /// <summary>
        /// Build a new <see cref="Order"/>.
        /// </summary>
        /// <param name="basket">The <see cref="Product"/>s the new <see cref="Order"/> is for.</param>
        /// <param name="customer">The <see cref="Customer"/> the new <see cref="Order"/> is for.</param>
        /// <param name="shippingAddress">The <see cref="Address"/> to send the <see cref="Order"/> too.</param>
        /// <returns>The new <see cref="Order"/>.</returns>
        public Order CreateOrder(Basket basket, Customer customer, Address shippingAddress)
        {
            var orderNumber = this._orderNumberGenerator.NextOrderNumber();

            var order = new Order
                        {
                            Basket = basket,
                            Customer = customer,
                            OrderNumber = orderNumber,
                            OrderDate = DateTime.UtcNow,
                            ShippingAddress = shippingAddress
                        };

            this._persistence.Add(order);

            this._persistence.Commit();

            return order;
        }