예제 #1
0
		public static LineItem generate(Order order, int sequence, Product product, long quantity)
		{
			LineItem item = new LineItem();
			item.order = order;
			item.sequence = sequence;
			item.product = product;
			item.quantity = quantity;
			item.order.LineItems.Insert(sequence, item);
			return item;
		}
			public void Prepare()
			{
				ISession session = outer.OpenSession();
				ITransaction transaction = session.BeginTransaction();

				lastMonth = DateTime.Today.AddMonths(-1);
				nextMonth = DateTime.Today.AddMonths(1);

				sixMonthsAgo = DateTime.Today.AddMonths(-6);
				fourMonthsAgo = DateTime.Today.AddMonths(-4);

				Department dept = new Department();
				dept.Name = ("Sales");

				session.Save(dept);
				deptId = dept.Id;
				entitiesToCleanUp.Add(dept);

				Salesperson steve = new Salesperson();
				steve.Name = ("steve");
				steve.Region = ("APAC");
				steve.HireDate = (sixMonthsAgo);

				steve.Department = (dept);
				dept.Salespersons.Add(steve);

				Salesperson max = new Salesperson();
				max.Name = ("max");
				max.Region = ("EMEA");
				max.HireDate = (nextMonth);

				max.Department = (dept);
				dept.Salespersons.Add(max);

				session.Save(steve);
				session.Save(max);
				entitiesToCleanUp.Add(steve);
				entitiesToCleanUp.Add(max);

				steveId = steve.Id;

				Category cat1 = new Category("test cat 1", lastMonth, nextMonth);
				Category cat2 = new Category("test cat 2", sixMonthsAgo, fourMonthsAgo);

				Product product1 = new Product();
				product1.Name = ("Acme Hair Gel");
				product1.StockNumber = (123);
				product1.EffectiveStartDate = (lastMonth);
				product1.EffectiveEndDate = (nextMonth);

				product1.AddCategory(cat1);
				product1.AddCategory(cat2);

				session.Save(product1);
				entitiesToCleanUp.Add(product1);
				prod1Id = product1.Id;

				Order order1 = new Order();
				order1.Buyer = "gavin";
				order1.Region = ("APAC");
				order1.PlacementDate = sixMonthsAgo;
				order1.FulfillmentDate = fourMonthsAgo;
				order1.Salesperson = steve;
				order1.AddLineItem(product1, 500);

				session.Save(order1);
				entitiesToCleanUp.Add(order1);

				Product product2 = new Product();
				product2.Name = ("Acme Super-Duper DTO Factory");
				product2.StockNumber = (124);
				product2.EffectiveStartDate = (sixMonthsAgo);
				product2.EffectiveEndDate = (DateTime.Today);

				Category cat3 = new Category("test cat 2", sixMonthsAgo, DateTime.Today);
				product2.AddCategory(cat3);

				session.Save(product2);
				entitiesToCleanUp.Add(product2);

				// An uncategorized product
				Product product3 = new Product();
				product3.Name = ("Uncategorized product");
				session.Save(product3);
				entitiesToCleanUp.Add(product3);

				Order order2 = new Order();
				order2.Buyer = "christian";
				order2.Region = ("EMEA");
				order2.PlacementDate = lastMonth;
				order2.Salesperson = steve;
				order2.AddLineItem(product2, -1);

				session.Save(order2);
				entitiesToCleanUp.Add(order2);

				transaction.Commit();
				session.Close();
			}
예제 #3
0
		public virtual LineItem AddLineItem(Product product, long quantity)
		{
			return LineItem.generate(this, LineItems.Count, product, quantity);
		}