本文整理匯總了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);
}
}