本文整理汇总了C#中SportsStore.Domain.Entities.Cart.TotalValue方法的典型用法代码示例。如果您正苦于以下问题:C# Cart.TotalValue方法的具体用法?C# Cart.TotalValue怎么用?C# Cart.TotalValue使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SportsStore.Domain.Entities.Cart
的用法示例。
在下文中一共展示了Cart.TotalValue方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ProcessOrder
public void ProcessOrder(Cart cart, ShippingDetails shippingDetails)
{
using (var smtpClient = new SmtpClient {
EnableSsl = emailSettings.UseSsl,
Host = emailSettings.ServerName,
Port = emailSettings.ServerPort,
UseDefaultCredentials = false,
Credentials = new NetworkCredential(emailSettings.Username, emailSettings.Password),
})
{
if (emailSettings.WriteAsFile)
{
smtpClient.DeliveryMethod = SmtpDeliveryMethod.SpecifiedPickupDirectory;
smtpClient.PickupDirectoryLocation = HttpContext.Current.Server.MapPath(emailSettings.FileLocation);
smtpClient.EnableSsl = false;
}
var 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.TotalValue())
.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");
var mailMessage = new MailMessage(emailSettings.MailFromAddress, emailSettings.MailtoAddress, "New order submitted!", body.ToString());
if (emailSettings.WriteAsFile)
mailMessage.BodyEncoding = Encoding.ASCII;
smtpClient.Send(mailMessage);
}
}