本文整理汇总了C#中Entities.ComputeTotalValue方法的典型用法代码示例。如果您正苦于以下问题:C# Entities.ComputeTotalValue方法的具体用法?C# Entities.ComputeTotalValue怎么用?C# Entities.ComputeTotalValue使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Entities
的用法示例。
在下文中一共展示了Entities.ComputeTotalValue方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ProcessOrder
public void ProcessOrder(Entities.Cart cart, Entities.ShippingDetails shippingInfo)
{
using (SmtpClient 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);
}
}
示例2: ProcessOrder
public void ProcessOrder(Entities.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("Order was processed")
.AppendLine("-----")
.AppendLine("Goods:");
foreach (var line in cart.Lines)
{
var subtotal = line.Game.Price * line.Quantity;
body.AppendFormat("{0} x {1} (General: {2:c}",
line.Quantity, line.Game.Name, subtotal);
}
body.AppendFormat("Total Cost: {0:c}", cart.ComputeTotalValue())
.AppendLine("---")
.AppendLine("Deliver:")
.AppendLine(shippingInfo.Name)
.AppendLine(shippingInfo.Line1)
.AppendLine(shippingInfo.Line2 ?? "")
.AppendLine(shippingInfo.Line3 ?? "")
.AppendLine(shippingInfo.City)
.AppendLine(shippingInfo.Country)
.AppendLine("---")
.AppendFormat("Gift Wrap: {0}",
shippingInfo.GiftWrap ? "Yes" : "No");
MailMessage mailMessage = new MailMessage(
_emailSettings.MailFromAddress,
_emailSettings.MailToAddress,
"New order was sent!",
body.ToString());
if (_emailSettings.WriteAsFile)
{
mailMessage.BodyEncoding = Encoding.UTF8;
}
smtpClient.Send(mailMessage);
}
}