コード例 #1
0
        private static Customer GetCustomerGraph()
        {
            var product = new Product {Price = 10m};

            var order = new Order
                            {
                                Status = OrderStatus.Shipped,
                                ShipDate = new DateTime(2010, 1, 2)
                            };

            order.AddOrderLine(2, product);

            var order1 = new Order
                         	{
                         		Status = OrderStatus.Shipped,
                         		ShipDate = new DateTime(2010, 1, 1)
                         	};

            order1.AddOrderLine(3, product);

            var customer = new Customer
                           	{
                           		Status = CustomerStatus.Normal,
                           		Name = new Name {First = "Joe", Last = "Smith"}
                           	};

            customer.AddOrder(order);
            customer.AddOrder(order1);

            return customer;
        }
コード例 #2
0
ファイル: Product.cs プロジェクト: wangn6/rep2
        public static Product AddProduct(Product instance)
        {
            using (ES1AutomationEntities context = new ES1AutomationEntities())
            {
                int productId = (from p in context.Products select p.ProductId).Max() + 1;

                if (Product.GetProductByID(productId) != null)
                {
                    return null;
                }

                instance.ProductId = productId;

                Product product = context.Products.Add(instance);
                context.SaveChanges();
                return product;
            }
        }
コード例 #3
0
        public IEnumerable<Customer> GetEverything()
        {
            var product = new Product
                          	{
                          		Id = 1,
                          		Name = "MT 1000 Computer Mouse",
                          		Description = "High speed gaming mouse",
                          		Price = 35M
                          	};

            var product2 = new Product
                           	{
                           		Id = 2,
                           		Name = "KeyTech Keyboard 107",
                           		Description = "Customizable 107 key keyboard for Windows",
                           		Price = 50M
                           	};

            var product3 = new Product
                           	{
                           		Id = 3,
                           		Name = "UberMon Display X60",
                           		Description = "24' LCD monitor",
                           		Price = 150M
                           	};

            var customer1 = new Customer
                                {
                                    Id = 1,
                                    Name = new Name("Jeffrey", "Palermo"),
                                    ShippingAddress = new Address
                                                      	{
                                                      		Line1 = "123 Any Street",
                                                      		City = "Austin",
                                                      		State = State.Texas,
                                                      		Zip = "78735"
                                                      	},
                                    Status = CustomerStatus.Gold
                                };

            var customer2 = new Customer
                                {
                                    Id = 2,
                                    Name = new Name("Eric", "Hexter") {Middle = "Michael", Suffix = Suffix.SR},
                                    ShippingAddress = new Address
                                                      	{
                                                      		Line1 = "400 Main Street",
                                                      		Line2 = "Suite 300",
                                                      		City = "Houston",
                                                      		State = State.Texas,
                                                      		Zip = "77722"
                                                      	},
                                    Status = CustomerStatus.Platinum,
                                };

            var customer3 = new Customer
                                {
                                    Id = 3,
                                    Name = new Name("Jimmy", "Bogard") {Suffix = Suffix.JR},
                                    ShippingAddress = new Address
                                                      	{
                                                      		Line1 = "One Microsoft Way",
                                                      		City = "Redmond",
                                                      		State = State.Washington,
                                                      		Zip = "98052"
                                                      	},
                                    Status = CustomerStatus.Gold
                                };

            var order = new Order(customer1);
            order.AddOrderLine(3, product);
            order.Place();
            order.Ship();

            var order1 = new Order(customer2);
            order1.AddOrderLine(4, product2);
            order1.AddOrderLine(2, product);
            order1.Place();
            order1.Ship();

            var order2 = new Order(customer3);
            order2.AddOrderLine(2, product3);
            order2.Place();
            order2.Ship();

            return new[] {customer1, customer2, customer3};
        }
コード例 #4
0
ファイル: Order.cs プロジェクト: jeffreypalermo/mvc2inaction
 public void AddOrderLine(int quantity, Product product)
 {
     var line = new OrderLine{Product = product, Quantity = quantity};
     _lines.Add(line);
 }
コード例 #5
0
ファイル: Core.DTO.cs プロジェクト: wangn6/rep2
        /// <summary>
        /// Invoked when <see cref="ToEntity"/> operation is about to return.
        /// </summary>
        /// <param name="entity"><see cref="Product"/> converted from <see cref="ProductDTO"/>.</param>
partial         static void OnEntity(this ProductDTO dto, Product entity);
コード例 #6
0
ファイル: Core.DTO.cs プロジェクト: wangn6/rep2
        /// <summary>
        /// Converts this instance of <see cref="ProductDTO"/> to an instance of <see cref="Product"/>.
        /// </summary>
        /// <param name="dto"><see cref="ProductDTO"/> to convert.</param>
        public static Product ToEntity(this ProductDTO dto)
        {
            if (dto == null) return null;

            var entity = new Product();

            entity.ProductId = dto.ProductId;
            entity.Name = dto.Name;
            entity.Description = dto.Description;
            entity.BuildProviderId = dto.BuildProviderId;
            entity.EnvironmentProviderId = dto.EnvironmentProviderId;
            entity.TestCaseProviderId = dto.TestCaseProviderId;
            entity.RunTime = dto.RunTime;
            entity.RQMProjectAlias = dto.RQMProjectAlias;

            dto.OnEntity(entity);

            return entity;
        }