当前位置: 首页>>代码示例>>C#>>正文


C# Customers.Insert方法代码示例

本文整理汇总了C#中Customers.Insert方法的典型用法代码示例。如果您正苦于以下问题:C# Customers.Insert方法的具体用法?C# Customers.Insert怎么用?C# Customers.Insert使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Customers的用法示例。


在下文中一共展示了Customers.Insert方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: LoadOrders

        public static void LoadOrders() {
            var _orders = new Orders();
            var _items = new OrderItems();
            var _customers = new Customers();
            var _productions = new Productions();
            dynamic _channels = new Channels();

            var orderID = 1001;
            var rand = new Random(100);

            Console.WriteLine("Blowing away dev data");
            _items.Delete();
            _orders.Delete();
            _customers.Delete();

            for (int i = 0; i < 1000; i++) {

                var month = rand.Next(1, 12);
                var day = rand.Next(1, 28);
                var orderDate = new DateTime(2011, month, day);

                Console.WriteLine("Adding " + i + " of 1000");
                var productID = 1;
                var price = 12.00;
                if (i > 250 && i < 500) {
                    productID = 2;
                    price = 15.00;
                } else if (i >= 500 && i < 750) {
                    productID = 3;
                    price = 18.00;
                } else if (i >= 750) {
                    productID = 4;
                    price = 10.00;
                }
                var p = _productions.Single(productID);
                var c = _channels.Single(p.ChannelID);
                var name = p.Title;
                var sku = p.Slug;
                var vendor = p.Author;
                var orderType = "single";
                //do a monthly every 5th one
                if (i % 5 == 0) {
                    name = "Monthly Subscription";
                    sku = "monthly";
                    vendor = "Tekpub";
                    price = 30.00;
                    orderType = "subscription";
                }

                //do an annual every 12th
                if (i % 12 == 0) {
                    name = "Annual Subscription";
                    sku = "yearly";
                    vendor = "Tekpub";
                    price = 279.00;
                    orderType = "subscription";
                }
                var tax = price * 0.0825;


                var newOrder = new {
                    OrderNumber = Guid.NewGuid().ToString(),
                    ShopifyID = orderID,
                    ShopifyName = "#" + orderID,
                    CreatedAt = orderDate,
                    Subtotal = price,
                    Token = Guid.NewGuid().ToString(),
                    Total = price + tax,
                    TaxIncluded = true,
                    LandingPage = "http://localhost",
                    ShopifyNumber = orderID,
                    Gateway = "bogus",
                    FulfillmentStatus = "fulfilled",
                    Currency = "USD",
                    ClosedAt = orderDate,
                    AcceptsMarketing = false,
                    Tax = tax,
                    IP = "127.0.0.1",
                    Weight = 1,
                    Email = i + "@example.com",
                };

                dynamic savedOrder = _orders.Insert(newOrder);
                //line items...
                for (int x = 1; x < 3; x++) {
                    var newItem = new {
                        OrderID = savedOrder.ID,
                        Name = name,
                        Price = price,
                        Quantity = x,
                        RequiresShipping = false,
                        Title = name,
                        Grams = 2,
                        SKU = sku,
                        Vendor = vendor,
                        OrderType = orderType,
                        Channel = c.Name
                    };
                    _items.Insert(newItem);

//.........这里部分代码省略.........
开发者ID:kodoroph,项目名称:mvc3,代码行数:101,代码来源:Program.cs


注:本文中的Customers.Insert方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。