示例#1
0
        public void Put_Customer_controller()
        {
            customerController.CManager.DeleteAllCustomer();

            var cus = new SampleCustomer {
                Name = "UnitTest", Adress = "UnitTestAdress"
            };

            customerController.PostCustomer(cus);
            Customer temp = customerController.CManager.GetAllCustomers().Last();

            SampleCustomer tempSample = customerController.GetCustomer(temp.ID).Value as SampleCustomer;

            Assert.Equal("UnitTestAdress", tempSample.Adress);
            Assert.Equal("UnitTest", tempSample.Name);

            var cus1 = new SampleCustomer {
                Name = "UnitTest1", Adress = "UnitTestAdress1"
            };

            customerController.PutCustomer(temp.ID, cus1);
            tempSample = customerController.GetCustomer(temp.ID).Value as SampleCustomer;
            Assert.Equal("UnitTestAdress1", tempSample.Adress);
            Assert.Equal("UnitTest1", tempSample.Name);

            customerController.CManager.DeleteAllCustomer();
        }
        public void Get_API_Orders()
        {
            orderController.DeleteAllCustomerOrders();
            customerController.CManager.DeleteAllCustomer();

            var cus = new SampleCustomer {
                Name = "UnitTest", Adress = "UnitTestAdress"
            };

            customerController.PostCustomer(cus);
            Customer temp = customerController.CManager.GetAllCustomers().Last();

            Assert.Equal("UnitTestAdress", temp.Adress);
            Assert.Equal("UnitTest", temp.Name);

            orderController.PostCustomerOrders(temp.ID, new SampleOrder {
                products = "Duvel", total = 1
            });

            Order       tempOrder  = orderController.OManager.Getall().Last();
            SampleOrder tempOrder2 = orderController.GetCustomerOrder(tempOrder.ID).Value;

            Assert.Equal("Duvel", tempOrder2.products);
            Assert.Equal(1, tempOrder2.total);
            orderController.DeleteAllCustomerOrders();
        }
        private void RunSample()
        {
            SampleCustomer c = new SampleCustomer("customer one", new DateTime(2010, 5, 31))
            {
                Reminders =
                {
                    { new DateTime(2010, 08, 12), "childs's birthday" },
                    { new DateTime(1012, 11, 15), "anniversary"       }
                }
            };

            SampleOrder o = new SampleOrder(new DateTime(2012, 6, 1), 5m);

            c.AddOrder(o);

            o = new SampleOrder(new DateTime(2103, 7, 4), 25m);
            c.AddOrder(o);

            // <SnippetHighlightCast>
            // Check the discount:
            ICustomer theCustomer = c;

            Console.WriteLine($"Current discount: {theCustomer.ComputeLoyaltyDiscount()}");
            // </SnippetHighlightCast>
            // </SnippetTestDefaultImplementation>

            // Add more orders to get the discount:
            DateTime recurring = new DateTime(2013, 3, 15);

            for (int i = 0; i < 15; i++)
            {
                o = new SampleOrder(recurring, 19.23m * i);
                c.AddOrder(o);

                recurring.AddMonths(2);
            }

            Console.WriteLine($"Data about {c.Name}");
            Console.WriteLine($"Joined on {c.DateJoined}. Made {c.PreviousOrders.Count()} orders, the last on {c.LastOrder}");
            Console.WriteLine("Reminders:");

            foreach (var item in c.Reminders)
            {
                Console.WriteLine($"\t{item.Value} on {item.Key}");
            }

            foreach (IOrder order in c.PreviousOrders)
            {
                Console.WriteLine($"Order on {order.Purchased} for {order.Cost}");
            }

            //
            Console.WriteLine($"Current discount: {theCustomer.ComputeLoyaltyDiscount()}");

            // <SnippetSetLoyaltyThresholds>
            ICustomer.SetLoyaltyThresholds(new TimeSpan(30, 0, 0, 0), 1, 0.25m);
            Console.WriteLine($"Current discount: {theCustomer.ComputeLoyaltyDiscount()}");
            // </SnippetSetLoyaltyThresholds>
        }
        /// <summary>
        /// This code comes from
        /// https://developers.docusign.com/esign-rest-api/code-examples/code-example-embedded-signing
        /// https://github.com/docusign/code-examples-csharp/blob/master/launcher-csharp/Controllers/Eg001EmbeddedSigningController.cs
        /// </summary>
        private RecipientViewRequest MakeRecipientViewRequest(HttpRequest request, SampleCustomer customer, string envelopeId)
        {
            // Construct the return url that Docusign will use when the signing ceremony is over
            var returnUrlFromConfig = this.Configuration["DocuSign:returnUrlForEmbeddedSigning"];
            var relativePath        = returnUrlFromConfig ?? "Docusign/EmbeddedSigningProcessor";

            if (relativePath.StartsWith('/'))  // strip leading slash
            {
                relativePath = relativePath.Substring(1);
            }

            string returnUrl =
                $"{request.Scheme}://{request.Host}/{relativePath}?email={customer.Email}&envelopeId={envelopeId}";

            // Set the url where you want the recipient to go once they are done signing
            // should typically be a callback route somewhere in your app.
            // The query parameter is included as an example of how
            // to save/recover state information during the redirect to
            // the DocuSign signing ceremony. It's usually better to use
            // the session mechanism of your web framework. Query parameters
            // can be changed/spoofed very easily.
            RecipientViewRequest viewRequest = new RecipientViewRequest
            {
                ReturnUrl = returnUrl,

                // How has your app authenticated the user? In addition to your app's
                // authentication, you can include authenticate steps from DocuSign.
                // Eg, SMS authentication
                AuthenticationMethod = "none",

                // Recipient information must match embedded recipient info
                // we used to create the envelope.
                Email        = customer.Email,
                UserName     = customer.Name,
                ClientUserId = customer.SignerId,

                // DocuSign recommends that you redirect to DocuSign for the
                // Signing Ceremony. There are multiple ways to save state.
                // To maintain your application's session, use the pingUrl
                // parameter. It causes the DocuSign Signing Ceremony web page
                // (not the DocuSign server) to send pings via AJAX to your
                // app,
                PingFrequency = "600",  // seconds

                // NOTE: The pings will only be sent if the pingUrl is an https address
                PingUrl = $"{request.Scheme}://{request.Host}"  // optional setting
            };

            return(viewRequest);
        }
示例#5
0
        public void Add_Customer_controller()
        {
            customerController.CManager.DeleteAllCustomer();

            var cus = new SampleCustomer {
                Name = "UnitTest", Adress = "UnitTestAdress"
            };

            customerController.PostCustomer(cus);
            Customer temp = customerController.CManager.GetAllCustomers().Last();

            Assert.Equal("UnitTestAdress", temp.Adress);
            Assert.Equal("UnitTest", temp.Name);

            customerController.CManager.DeleteAllCustomer();
        }
        public void Delete_API_Orders()
        {
            orderController.DeleteAllCustomerOrders();
            customerController.CManager.DeleteAllCustomer();

            var cus = new SampleCustomer {
                Name = "UnitTest", Adress = "UnitTestAdress"
            };

            customerController.PostCustomer(cus);
            Customer temp = customerController.CManager.GetAllCustomers().Last();

            Assert.Equal("UnitTestAdress", temp.Adress);
            Assert.Equal("UnitTest", temp.Name);

            orderController.PostCustomerOrders(temp.ID, new SampleOrder {
                products = "Duvel", total = 1
            });
            orderController.PostCustomerOrders(temp.ID, new SampleOrder {
                products = "Orval", total = 2
            });
            orderController.PostCustomerOrders(temp.ID, new SampleOrder {
                products = "Leffe", total = 3
            });

            var tempOrder = orderController.GetAllOrders().Value;

            Assert.Equal("Duvel", tempOrder[0].products);
            Assert.Equal(1, tempOrder[0].total);
            Assert.Equal("Orval", tempOrder[1].products);
            Assert.Equal(2, tempOrder[1].total);
            Assert.Equal("Leffe", tempOrder[2].products);
            Assert.Equal(3, tempOrder[2].total);
            var ID = tempOrder[1].ID.Split("/")[6];

            orderController.DeleteCustomerOrders(temp.ID, Int32.Parse(ID));
            tempOrder = orderController.GetAllOrders().Value;
            Assert.Equal(2, tempOrder.Count);


            orderController.DeleteAllCustomerOrders();
        }
示例#7
0
        public static void Test_Default_Interface_Methods()
        {
            ICustomer.SetLoyaltyThresholds(-2, 0.20m);
            SampleCustomer c1 = new SampleCustomer("John Smith", new DateTime(2020, 1, 23));
            SampleCustomer c2 = new SampleCustomer("Mary Smith", new DateTime(2017, 2, 15), new DateTime(2009, 4, 15), new DateTime(2005, 6, 1));
            SampleCustomer c3 = new SampleCustomer("Kim Smith", new DateTime(2020, 3, 13));

            SampleOrder o1 = new SampleOrder(new DateTime(2019, 12, 11), 150.67m);
            SampleOrder o2 = new SampleOrder(new DateTime(2019, 10, 11), 50.67m);

            c1.AddOrder(o1);
            c2.AddOrder(o2);

            Console.WriteLine($"Discount for {c1.Name} is {c1.ComputeLoyaltyDiscount()}"); //calls ComputeLoyaltyDiscount of the SampleCustomer

            Console.WriteLine($"Discount for {c2.Name} is {c2.ComputeLoyaltyDiscount()}");
            Console.WriteLine($"Discount for {c3.Name} is {c3.ComputeLoyaltyDiscount()}");
            ICustomer c = c3;

            Console.WriteLine($"ICustomer Discount for {c3.Name} is {c.ComputeLoyaltyDiscount()}");
        }
示例#8
0
        private static void CallDefaultInterfaceMethods()
        {
            SampleCustomer c = new SampleCustomer("customer one", new DateTime(2010, 5, 31))
            {
                Reminders =
                {
                    { new DateTime(2010, 08, 12), "childs's birthday" },
                    { new DateTime(1012, 11, 15), "anniversary"       }
                }
            };

            SampleOrder o = new SampleOrder(new DateTime(2012, 6, 1), 5m);

            c.AddOrder(o);

            o = new SampleOrder(new DateTime(2103, 7, 4), 25m);
            c.AddOrder(o);

            /*
             *  実装先のクラス(SampleCustomer)で関数をオーバーライドしていない限り、
             *  インターフェースへのキャストが必須である事に注意!
             *
             */
            ICustomer theCustomer = c;

            ICustomer.SetLoyaltyThreshholds(new TimeSpan(30, 0, 0, 0), 1, 0.25m);
            Console.WriteLine($"Current Discount: {theCustomer.ComputeLoyaltyDiscount()}");

            Console.WriteLine($"Data about {c.Name}");
            Console.WriteLine($"Joined on {c.DateJoined}. Made {c.PreviousOrders.Count()} orders, the last on {c.LastOrder}");
            Console.WriteLine("Reminders:");
            foreach (var item in c.Reminders)
            {
                Console.WriteLine($"\t{item.Value} on {item.Key}");
            }
            foreach (IOrder order in c.PreviousOrders)
            {
                Console.WriteLine($"Order on {order.Purchased} for {order.Cost}");
            }
        }
示例#9
0
        public void Run()
        {
            SampleCustomer c = new SampleCustomer("customer one", new DateTime(2010, 5, 31))
            {
                Reminders =
                {
                    { new DateTime(2010, 08, 12), "childs's birthday" },
                    { new DateTime(1012, 11, 15), "anniversary"       }
                }
            };


            SampleOrder o = new SampleOrder(new DateTime(2012, 6, 1), 5m);

            c.AddOrder(o);

            o = new SampleOrder(new DateTime(2103, 7, 4), 25m);
            c.AddOrder(o);

            // Check the discount:
            // Check the discount:
            ICustomer theCustomer = c;
            //Console.WriteLine($"Current discount: {theCustomer.ComputeLoyaltyDiscount()}");
        }
        private EnvelopeDefinition CreateEnvelopeFromTemplate(EnvelopeTemplate docusignTemplate, SampleCustomer customer)
        {
            var envelopeDefinition = new EnvelopeDefinition
            {
                TemplateId    = docusignTemplate.TemplateId,
                Status        = "sent",
                TemplateRoles = new List <TemplateRole>
                {
                    new TemplateRole
                    {
                        Email    = customer.Email,
                        Name     = customer.Name,
                        RoleName = "Signer",
                        Tabs     = new Tabs(TitleTabs: new List <Title> {
                            new Title {
                                Value = customer.Title
                            }
                        })
                    }
                },
            };

            // If we are using embedded signing, then the signer id in the envelope must match the signer id in the ReceipientView
            if (!string.IsNullOrEmpty(customer.SignerId))
            {
                envelopeDefinition.TemplateRoles[0].ClientUserId = customer.SignerId;
            }

            return(envelopeDefinition);
        }