Exemplo n.º 1
0
		public LineItem LineItem_ForOrder( Order order, int quantity, double price )
		{
			LineItem lineItem = LineItem_ForOrder( order );
			lineItem.Quantity = quantity;
			lineItem.UnitPrice = price;
			return lineItem;
		}
Exemplo n.º 2
0
        public OrderViewModel()
        {
            order = CreateOrder();
            addressViewModel = new AddressViewModel(order.DeliveryAddress);

            order.PropertyChanged += (s, e) =>
                                         {
                                             if (e.PropertyName == "NeedDelivery")
                                             {
                                                 UpdateAddressVadliationEnabled();
                                             }
                                         };
            SubmitCommand = new SimpleCommand
                                {
                                    ExecuteDelegate = p =>
                                                          {
                                                              ValidationEnabled = true;
                                                              if (Order.IsValid) Submit();
                                                          },
                                    CanExecuteDelegate = p => !ValidationEnabled || Order.IsValid
                                };
            ResetCommand = new SimpleCommand
                               {
                                   ExecuteDelegate = p => ValidationEnabled = false
                               };
        }
Exemplo n.º 3
0
		public Order Order()
		{
			var order = new Order
			            	{
			            			Id = GetUniqueId(),
			            			Customer = Customer(),
			            			OrderDate = ARandom.DateTime(),
			            			LineItems = LineItems( 3 )
			            	};
			return order;
		}
Exemplo n.º 4
0
		public TestDatabase Add( Order order )
		{
			// Exit if null or if this has already been added.
			if ( _orders.AddIfUnique( order, x => x.Id == order.Id ) )
			{
				// Add parents.
				Add( order.Customer );

				// Add children.
				Add( order.LineItems );
			}
			return this;
		}
		public void OrderTotalShouldBeTheSumOfTheLineItems()
		{
			// Arrange.
			var customer = new Customer
			               	{
			               			FirstName = "Bob",
			               			LastName = "Smith"
			               	};

			var order = new Order
			            	{
			            			Customer = customer,
			            			OrderDate = DateTime.Now
			            	};

			var lineItem1 = new LineItem
			                	{
			                			Order = order,
			                			Product = new Product
			                			          	{
			                			          			Name = "Product1",
			                			          			Description = "Product1 Description"
			                			          	},
			                			Quantity = 1,
			                			UnitPrice = 1.60
			                	};

			var lineItem2 = new LineItem
			                	{
			                			Order = order,
			                			Product = new Product
			                			          	{
			                			          			Name = "Product2",
			                			          			Description = "Product2 Description"
			                			          	},
			                			Quantity = 10,
			                			UnitPrice = 25.99
			                	};

			order.LineItems.Add( lineItem1 );
			order.LineItems.Add( lineItem2 );


			// Act.
			var actualTotal = order.TotalAmount;


			// Assert.
			const double expectedTotal = ( 1 * 1.60 ) + ( 10 * 25.99 );
			actualTotal.Should().Be.EqualTo( expectedTotal );
		}
Exemplo n.º 6
0
		public void Insert( Order order )
		{
			IDbCommand command = _session.CreateCommandWithinCurrentTransaction();

			command.CommandText = SqlGenerator.GenerateInsertSql(
					"Order",
					new[]
						{
								"Id",
								"Customer_id"
						},
					//HasIdentityColumn );
					HasNoIdentityColumn );

			command.SetParameter( "@Id", order.Id );
			command.SetParameter( "@Customer_id", order.Customer.Id );

			LogCommand( command );
			command.ExecuteNonQuery();
		}
Exemplo n.º 7
0
		public LineItem LineItem_ForOrderAndProduct( Order order, Product product )
		{
			LineItem lineItem = LineItem_ForOrder( order );
			lineItem.Product = product;
			return lineItem;
		}
Exemplo n.º 8
0
		public LineItem LineItem_ForOrder( Order order )
		{
			LineItem lineItem = LineItem();
			lineItem.Order = order;
			return lineItem;
		}