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


C# Entities.ShippingDetails类代码示例

本文整理汇总了C#中SportsStore.Domain.Entities.ShippingDetails的典型用法代码示例。如果您正苦于以下问题:C# ShippingDetails类的具体用法?C# ShippingDetails怎么用?C# ShippingDetails使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


ShippingDetails类属于SportsStore.Domain.Entities命名空间,在下文中一共展示了ShippingDetails类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: CombineMessage

        private string CombineMessage(Cart cart, ShippingDetails shippingDetails)
        {
            StringBuilder body = new StringBuilder()
                    .AppendLine("A new order has been submitted")
                    .AppendLine("---")
                    .AppendLine("Items:");

            foreach (var line in cart.Lines)
            {
                var subtotal = line.Product.Price * line.Quantity;
                body.AppendFormat("{0} x {1} (subtotal: {2:c})", line.Quantity, line.Product.Name, subtotal);
            }

            body.AppendFormat("Total order value: {0:c}", cart.ComputeTotalValue())
                .AppendLine("---")
                .AppendLine("Ship to:")
                .AppendLine(shippingDetails.Name)
                .AppendLine(shippingDetails.Line1)
                .AppendLine(shippingDetails.Line2 ?? "")
                .AppendLine(shippingDetails.Line3 ?? "")
                .AppendLine(shippingDetails.City)
                .AppendLine(shippingDetails.State ?? "")
                .AppendLine(shippingDetails.Country)
                .AppendLine(shippingDetails.Zip)
                .AppendLine("---")
                .AppendFormat("Gift wrap: {0}", shippingDetails.GiftWrap ? "Yes" : "No");

            return body.ToString();
        }
开发者ID:brainiacOnly,项目名称:SportsStore,代码行数:29,代码来源:InternetEmailOrderProcessor.cs

示例2: ProcessOrder

        public void ProcessOrder(Cart cart, ShippingDetails shippingInfo) {

            using (var smtpClient = new SmtpClient()) {

                smtpClient.EnableSsl = emailSettings.UseSsl;
                smtpClient.Host = emailSettings.ServerName;
                smtpClient.Port = emailSettings.ServerPort;
                smtpClient.UseDefaultCredentials = false;
                smtpClient.Credentials
                    = new NetworkCredential(emailSettings.Username,
                          emailSettings.Password);

                if (emailSettings.WriteAsFile) {
                    smtpClient.DeliveryMethod
                        = SmtpDeliveryMethod.SpecifiedPickupDirectory;
                    smtpClient.PickupDirectoryLocation = emailSettings.FileLocation;
                    smtpClient.EnableSsl = false;
                }

                StringBuilder body = new StringBuilder()
                    .AppendLine("A new order has been submitted")
                    .AppendLine("---")
                    .AppendLine("Items:");

                foreach (var line in cart.Lines) {
                    var subtotal = line.Product.Price * line.Quantity;
                    body.AppendFormat("{0} x {1} (subtotal: {2:c}", line.Quantity,
                                      line.Product.Name,
                                      subtotal);
                }

                body.AppendFormat("Total order value: {0:c}", cart.ComputeTotalValue())
                    .AppendLine("---")
                    .AppendLine("Ship to:")
                    .AppendLine(shippingInfo.Name)
                    .AppendLine(shippingInfo.Line1)
                    .AppendLine(shippingInfo.Line2 ?? "")
                    .AppendLine(shippingInfo.Line3 ?? "")
                    .AppendLine(shippingInfo.City)
                    .AppendLine(shippingInfo.State ?? "")
                    .AppendLine(shippingInfo.Country)
                    .AppendLine(shippingInfo.Zip)
                    .AppendLine("---")
                    .AppendFormat("Gift wrap: {0}",
                        shippingInfo.GiftWrap ? "Yes" : "No");

                MailMessage mailMessage = new MailMessage(
                                       emailSettings.MailFromAddress,   // From
                                       emailSettings.MailToAddress,     // To
                                       "New order submitted!",          // Subject
                                       body.ToString());                // Body

                if (emailSettings.WriteAsFile) {
                    mailMessage.BodyEncoding = Encoding.ASCII;
                }

                //smtpClient.Send(mailMessage);
               
            }
        }
开发者ID:rogerertas,项目名称:SportsStore,代码行数:60,代码来源:EmailOrderProcessor.cs

示例3: BuildMailMessage

 private MailMessage BuildMailMessage(Cart cart, ShippingDetails shippingDetails)
 {
     StringBuilder body = new StringBuilder();
     body.AppendLine("A new order has been submitted");
     body.AppendLine("---");
     body.AppendLine("Items:");
     foreach (var line in cart.Lines) {
         var subtotal = line.Product.Price * line.Quantity;
         body.AppendFormat("{0} x {1} (subtotal: {2:c}", line.Quantity,
                           line.Product.Name,
                           subtotal);
     }
     body.AppendFormat("Total order value: {0:c}", cart.ComputeTotalValue());
     body.AppendLine("---");
     body.AppendLine("Ship to:");
     body.AppendLine(shippingDetails.Name);
     body.AppendLine(shippingDetails.Line1);
     body.AppendLine(shippingDetails.Line2 ?? "");
     body.AppendLine(shippingDetails.Line3 ?? "");
     body.AppendLine(shippingDetails.City);
     body.AppendLine(shippingDetails.State ?? "");
     body.AppendLine(shippingDetails.Country);
     body.AppendLine(shippingDetails.Zip);
     body.AppendLine("---");
     body.AppendFormat("Gift wrap: {0}", shippingDetails.GiftWrap ? "Yes" : "No");
     return new MailMessage("[email protected]", // From
                            mailTo,                    // To
                            "New order submitted!",    // Subject
                            body.ToString());          // Body
 }
开发者ID:sbetchel,项目名称:SportsStore,代码行数:30,代码来源:EmailOrderSubmitter.cs

示例4: Can_Send_Email

        public void Can_Send_Email() {

            // Arrange - create and populate a cart
            Cart cart = new Cart();
            cart.AddItem(new Product { ProductID = 1, Name = "Banana", Price = 10M }, 2);
            cart.AddItem(new Product { ProductID = 2, Name = "Apple", Price = 5M }, 2);

            // Arrange - create and populate some shipping details
            ShippingDetails shipDetails = new ShippingDetails {
                Name = "Joe Smith",
                Line1 = "Apartment 4a",
                Line2 = "123 West Street",
                City = "Northtown",
                State = "GA",
                Country = "USA",
                Zip = "12345"
            };

            // Arrange - create the test-specific email settings
            EmailSettings settings = new EmailSettings {
            
                // put test specific settings here
                WriteAsFile = true
            };

            // Arrange - create the EmailOrderProcessor class
            EmailOrderProcessor proc = new EmailOrderProcessor(settings);

            // Act - process the order
            proc.ProcessOrder(cart, shipDetails);

            // NOTE - there is assert in this test

        }
开发者ID:evkap,项目名称:AspNetMvcTestApp,代码行数:34,代码来源:EmailOrderProcessorTest.cs

示例5: ProcessOrder

        public void ProcessOrder(Cart cart, ShippingDetails shippingInfo)
        {
            using (var smtpClient = new SmtpClient())
            {

            }
        }
开发者ID:NobodyWHU,项目名称:SportsStore,代码行数:7,代码来源:EmailOrderProcessor.cs

示例6: ProcessorOrder

        public void ProcessorOrder(Cart cart, ShippingDetails shipping)
        {
            using(var smtpClient = new SmtpClient(emailSettings.Servername, emailSettings.Serverport))
            {
                smtpClient.EnableSsl = emailSettings.UseSsl;
                smtpClient.UseDefaultCredentials = false;
                smtpClient.Credentials = new NetworkCredential(emailSettings.Username, emailSettings.Password);

                if(emailSettings.WriteAsFile)
                {
                    smtpClient.DeliveryMethod = SmtpDeliveryMethod.SpecifiedPickupDirectory;
                    smtpClient.PickupDirectoryLocation = emailSettings.FileLocation;
                    smtpClient.EnableSsl = false;
                }

                StringBuilder body = new StringBuilder();
                body.AppendLine("A new order has been submitted");
                body.AppendLine("---");
                body.AppendLine("Items: ");

                foreach (var item in cart.Lines)
                {
                    var subtotal = item.Product.Price*item.Quantity;
                    body.AppendFormat("{0} x {1} (subtotal: {2})", item.Quantity, item.Product.Price, subtotal.ToString("c"));
                }

                body.AppendFormat("Total order value: {0}", cart.ComputeTotalValue().ToString("c"))
                    .AppendLine("---")
                    .AppendLine("Ship to: ")
                    .AppendLine(shipping.Name)
                    .AppendLine(shipping.Line1)
                    .AppendLine(shipping.Line2 ?? "")
                    .AppendLine(shipping.Line3 ?? "")
                    .AppendLine(shipping.City)
                    .AppendLine(shipping.State ?? "")
                    .AppendLine(shipping.Country)
                    .AppendLine(shipping.Zip)
                    .AppendLine("---")
                    .AppendFormat("Gift wrap: {0}",  shipping.GiftWrap ? "Yes" : "No")
                    ;

                MailMessage mailMessage = new MailMessage(emailSettings.MailFromAddress, emailSettings.MailToAddress, "New order submitted!", body.ToString());

                if(emailSettings.WriteAsFile)
                {
                    mailMessage.BodyEncoding = Encoding.ASCII;
                }

                try
                {
                    smtpClient.Send(mailMessage);
                }
                catch (Exception exception)
                {
                    Debug.WriteLine("Couldn't send mail: " + exception.Message);

                }

            }
        }
开发者ID:Gluba,项目名称:SportsStore,代码行数:60,代码来源:EmailOrderProcessor.cs

示例7: Cannot_Checkout_Empty_Cart

        public void Cannot_Checkout_Empty_Cart()
        {
            // Arrange - create a mock order processor
            Mock<IOrderProcessor> mock = new Mock<IOrderProcessor>();

            // Arrange - create an empty cart
            Cart cart = new Cart();

            // Arrange - create shipping details
            ShippingDetails shippingDetails = new ShippingDetails();

            // Arrange - create an instance of the controller
            CartController target = new CartController(null, mock.Object);

            // Act
            ViewResult result = target.Checkout(cart, shippingDetails);

            // Assert - check that the order hasn't been passed on to the processor
            mock.Verify(m => m.ProcessOrder(It.IsAny<Cart>(), It.IsAny<ShippingDetails>()),
            Times.Never());

            // Assert - check that the method is returning the default view
            Assert.AreEqual("", result.ViewName);

            // Assert - check that we are passing an invalid model to the view
            Assert.AreEqual(false, result.ViewData.ModelState.IsValid);
        }
开发者ID:digitalsol,项目名称:SportsDepo,代码行数:27,代码来源:CartControllerTest.cs

示例8: ProcessOrder

        public void ProcessOrder(Cart cart, ShippingDetails shippingInfo) {

            using (var smtpClient = new SmtpClient()) {

                smtpClient.EnableSsl = emailSettings.UseSsl;
                smtpClient.Host = emailSettings.ServerName;
                smtpClient.Port = emailSettings.ServerPort;
                smtpClient.UseDefaultCredentials = false;
                smtpClient.Credentials
                    = new NetworkCredential(emailSettings.Username,
                          emailSettings.Password);

                if (emailSettings.WriteAsFile) {
                    smtpClient.DeliveryMethod
                        = SmtpDeliveryMethod.SpecifiedPickupDirectory;
                    smtpClient.PickupDirectoryLocation = emailSettings.FileLocation;
                    smtpClient.EnableSsl = false;
                }

                var body = buildMessageBody(cart, shippingInfo);

                MailMessage mailMessage = new MailMessage(
                                       emailSettings.MailFromAddress,   // From
                                       emailSettings.MailToAddress,     // To
                                       "New order submitted!",          // Subject
                                       body.ToString());                // Body

                if (emailSettings.WriteAsFile) {
                    mailMessage.BodyEncoding = Encoding.ASCII;
                }

                smtpClient.Send(mailMessage);
            }
        }
开发者ID:Geronimobile,项目名称:DotNetExamIntro,代码行数:34,代码来源:EmailOrderProcessor.cs

示例9: Cannot_Checkout_Empty_Cart

        public void Cannot_Checkout_Empty_Cart()
        {
            // Arragne - Mock 주문 처리기 생성
            Mock<IOrderProcessor> mock = new Mock<IOrderProcessor>();
            // Arrange - 빈 Cart 개체 생성
            Cart cart = new Cart();

            // Arragne - 배송 정보 생성
            ShippingDetails shippingDetails = new ShippingDetails();

            // Arrange - 컨트롤러의 인스턴스 생성
            CartController target = new CartController(null, mock.Object);

            // Act
            ViewResult result = target.Checkout(cart, shippingDetails);

            // Assert - 주문이 주문 처리기에 전달되지 않은 것을 확인한다.
            mock.Verify(m => m.ProcessOrder(It.IsAny<Cart>(), It.IsAny<ShippingDetails>()),
                Times.Never());
            // Assert - 메서드가 기본 뷰를 반환했는지 확인한다.
            Assert.AreEqual("", result.ViewName);

            // Assert - 유효하지 않은 모델을 뷰에 전달하는지 확인한다
            Assert.AreEqual(false, result.ViewData.ModelState.IsValid);
        }
开发者ID:EthanK28,项目名称:pro-asp-mvc5,代码行数:25,代码来源:CartTests.cs

示例10: ProcessOrder

        public void ProcessOrder(Cart cart, ShippingDetails shippingInfo)
        {
            using (var smtpClient = new SmtpClient())
            {
                smtpClient.EnableSsl = emailSettings.UseSsl;
                smtpClient.Host = emailSettings.ServerName;
                smtpClient.Port = emailSettings.ServerPort;
                smtpClient.DeliveryMethod = SmtpDeliveryMethod.Network;
                smtpClient.UseDefaultCredentials = false;
                smtpClient.Credentials = new NetworkCredential(emailSettings.UserName, emailSettings.Password);
                smtpClient.Timeout = 10000;

                if (emailSettings.WriteAsFile)
                {
                    smtpClient.DeliveryMethod = SmtpDeliveryMethod.SpecifiedPickupDirectory;
                    smtpClient.PickupDirectoryLocation = emailSettings.FileLocation;
                    smtpClient.EnableSsl = false;
                }

                StringBuilder body = new StringBuilder()
                    .AppendLine("Nowe zamówienie")
                    .AppendLine("---")
                    .AppendLine("Produkty:");

                foreach (var line in cart.Lines)
                {
                    var subtotal = line.Product.Price*line.Quantity;
                    body.AppendFormat("{0} x {1} (wartość: {2:c})", line.Quantity, line.Product.Name, subtotal);
                }

                body.AppendFormat("Wartosc calkowita:{0:c}", cart.ComputeTotalValue())
                    .AppendLine("---")
                    .AppendLine("Wysylka dla:")
                    .AppendLine(shippingInfo.Name)
                    .AppendLine(shippingInfo.Line1)
                    .AppendLine(shippingInfo.Line2 ?? "")
                    .AppendLine(shippingInfo.Line3 ?? "")
                    .AppendLine(shippingInfo.City)
                    .AppendLine(shippingInfo.State ?? "")
                    .AppendLine(shippingInfo.Country)
                    .AppendLine(shippingInfo.Zip)
                    .AppendLine("---")
                    .AppendFormat("Pakowanie prezentu: {0}", shippingInfo.GiftWrap ? "Tak" : "Nie");

                MailMessage mailMessage = new MailMessage(
                    emailSettings.MailFromAddress,
                    emailSettings.MailToAddress,
                    "Otrzymano nowe zamówienie!",
                    body.ToString());
                mailMessage.Priority = MailPriority.High;

                if (emailSettings.WriteAsFile)
                {
                    mailMessage.BodyEncoding = Encoding.ASCII;
                }

                smtpClient.Send(mailMessage);
            }
        }
开发者ID:SHassona,项目名称:Personal-Repository,代码行数:59,代码来源:EmailOrderProcessor.cs

示例11: SubmitOrder

 public void SubmitOrder(Cart cart, ShippingDetails shippingDetails)
 {
     using (var smtpClient = new SmtpClient())
     using (var mailMessage = BuildMailMessage(cart, shippingDetails))
     {
         smtpClient.Send(mailMessage);
     }
 }
开发者ID:astrateg,项目名称:SportsStore,代码行数:8,代码来源:EmailOrderSubmitter.cs

示例12: CheckOut

 public ViewResult CheckOut(Cart cart, ShippingDetails Details)
 {
     if (!cart.Lines.Any())
     {
         ModelState.AddModelError("", "Cart is empty");
     }
     return View();
 }
开发者ID:CacoDurban,项目名称:SportsStore,代码行数:8,代码来源:CartController.cs

示例13: SubmitOrder

 public void SubmitOrder(Cart cart, ShippingDetails shippingDetails)
 {
     // If you're using .NET 4, you need to dispose the objects, so write this:
     using (var smtpClient = new SmtpClient())
     using (var mailMessage = BuildMailMessage(cart, shippingDetails)) {
         smtpClient.Send(mailMessage);
     }
 }
开发者ID:sbetchel,项目名称:SportsStore,代码行数:8,代码来源:EmailOrderSubmitter.cs

示例14: Cannot_Check_Out_If_Cart_Is_Empty

        public void Cannot_Check_Out_If_Cart_Is_Empty()
        {
            var emptyCart = new Cart();
            var shippingDetails = new ShippingDetails();

            var result = new CartController(null, null).CheckOut(emptyCart, shippingDetails);

            result.ShouldBeDefaultView();
        }
开发者ID:hcabnettek,项目名称:SportsStore,代码行数:9,代码来源:ShoppingCart.cs

示例15: ProcessOrder

        public void ProcessOrder(Cart cart, ShippingDetails shippingDetails)
        {
            using (var smtpClient = new SmtpClient())
            {
                smtpClient.EnableSsl = emailSettings.UseSsl;
                smtpClient.Host = emailSettings.ServerName;
                smtpClient.Port = emailSettings.ServerPort;
                smtpClient.UseDefaultCredentials = false;
                smtpClient.Credentials = new NetworkCredential(emailSettings.Username, emailSettings.Password);

                if (emailSettings.WriteAsFile)
                {
                    smtpClient.DeliveryMethod = SmtpDeliveryMethod.SpecifiedPickupDirectory;
                    smtpClient.PickupDirectoryLocation = emailSettings.FileLocation;
                    smtpClient.EnableSsl = false;
                }

                StringBuilder body = new StringBuilder()
                    .AppendLine("A new order has being submitted")
                    .AppendLine("---")
                    .AppendLine("Items:");

                foreach (var line in cart.Lines)
                {
                    var subtotal = line.Product.Price * line.Quantity;
                    body.AppendFormat("{0} x {1} (subtotal: {2:c})", line.Quantity, line.Product.Name, subtotal);
                }

                body.AppendFormat("Total order value: {0:c}", cart.ComputeTotalValue())
                    .AppendLine("---")
                    .AppendLine("Ship to")
                    .AppendLine(shippingDetails.Name)
                    .AppendLine(shippingDetails.Line1)
                    .AppendLine(shippingDetails.Line2 ?? "")
                    .AppendLine(shippingDetails.Line3 ?? "")
                    .AppendLine(shippingDetails.City)
                    .AppendLine(shippingDetails.Zip ?? "")
                    .AppendLine(shippingDetails.Country)
                    .AppendLine("---")
                    .AppendFormat("Gift wrap: {0}", shippingDetails.GiftWrap ? "Yes" : "No");

                MailMessage message = new MailMessage();
                AlternateView plainView = AlternateView.CreateAlternateViewFromString(body.ToString(), null, MediaTypeNames.Text.Plain);
                message.From = new MailAddress(emailSettings.MailFromAddress);
                message.To.Add(emailSettings.MailToAddress);
                message.Subject = "New order submitted";
                message.AlternateViews.Add(plainView);

                if (emailSettings.WriteAsFile)
                {
                    message.BodyEncoding = Encoding.ASCII;
                }

                smtpClient.Send(message);
            }
        }
开发者ID:djandreski,项目名称:SportsStore,代码行数:56,代码来源:EmailOrderProcessor.cs


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