コード例 #1
0
        /// <summary>
        /// Add a new <see cref="Address"/> to a <see cref="Customer"/>.
        /// </summary>
        /// <param name="customer">The <see cref="Customer"/> to add an <see cref="Address"/> too.</param>
        /// <param name="newAddress">The new <see cref="Address"/> for the <paramref name="customer"/>.</param>
        /// <returns>The <see cref="Customer"/>.</returns>
        public Customer AddAddress(Customer customer, Address newAddress)
        {
            customer.Addresses.Add(newAddress);

            this._persistence.Change(customer);

            this._persistence.Commit();

            return customer;
        }
コード例 #2
0
        /// <summary>
        /// Build a new <see cref="Model.Customer.Customer"/>.
        /// </summary>
        /// <param name="firstName">The <see cref="Model.Customer.Customer"/>s first name.</param>
        /// <param name="lastName">The <see cref="Customer"/>s last name.</param>
        /// <param name="email">The <see cref="Customer"/>s email address.</param>
        /// <param name="address">The <see cref="Customer"/>s primary <see cref="Address"/>.</param>
        /// <returns>The new <see cref="Customer"/>.</returns>
        public Customer CreateCustomer(string firstName, string lastName, string email, Address address)
        {
            var customer = new Customer
                           {
                               Addresses = new Collection<Address>(),
                               Email = email,
                               FirstName = firstName,
                               LastName = lastName
                           };

            customer.SetNewId(Guid.NewGuid());

            if(address != null)
            {
                customer.Addresses.Add(address);
            }

            this._persistence.Add(customer);

            this._persistence.Commit();

            return customer;
        }
コード例 #3
0
ファイル: OrderManager.cs プロジェクト: dibble-james/Ketchup
        /// <summary>
        /// Retrieve all <see cref="Order"/>s for a given <see cref="Customer"/>.
        /// </summary>
        /// <param name="customer">The <see cref="Customer"/> to find <see cref="Order"/>s for.</param>
        /// <returns>All <see cref="Order"/>s for a given <see cref="Customer"/>.</returns>
        public IEnumerable<Order> GetOrders(Customer customer)
        {
            var orders =
                this._persistence.Find(
                    new PersistenceCollectionSearcher<Order>(o => o.Customer.Id == customer.Id));

            return orders;
        }
コード例 #4
0
ファイル: OrderManager.cs プロジェクト: dibble-james/Ketchup
        /// <summary>
        /// Retrieve an <see cref="Order"/> for a given <paramref name="customer"/> on a given <paramref name="orderDate"/>.
        /// </summary>
        /// <param name="customer">The <see cref="Customer"/> to retrieve an <see cref="Order"/> for.</param>
        /// <param name="orderDate">The <see cref="System.DateTime"/> the order was made upon.</param>
        /// <returns>
        /// An <see cref="Order"/> with the matching <paramref name="customer"/> and <paramref name="orderDate"/> 
        /// or null if no <see cref="Order"/>s match.
        /// </returns>
        public Order GetOrder(Customer customer, DateTime orderDate)
        {
            var order =
                this._persistence.Find(
                    new PersistenceSearcher<Order>(o => o.Customer.Id == customer.Id && o.OrderDate == orderDate));

            return order;
        }
コード例 #5
0
ファイル: OrderManager.cs プロジェクト: dibble-james/Ketchup
        /// <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;
        }
 public void Save(Customer customer)
 {
     _azureTable.Upsert(customer.Map());
 }