コード例 #1
0
 public void ProceseOrder(Cart cart, SheepingDetails details)
 {
     using (SmtpClient smtp = new SmtpClient())
     {
         smtp.EnableSsl             = settings.useSsl;
         smtp.Host                  = settings.serverName;
         smtp.Port                  = settings.serverPort;
         smtp.UseDefaultCredentials = false;
         smtp.Credentials           = new NetworkCredential(settings.userName, settings.password);
         if (settings.writeAsFie)
         {
             smtp.DeliveryMethod          = SmtpDeliveryMethod.SpecifiedPickupDirectory;
             smtp.PickupDirectoryLocation = settings.fileLocation;
             smtp.EnableSsl = false;
         }
         StringBuilder body = new StringBuilder().AppendLine("Your Order is ready")
                              .AppendLine("--------")
                              .AppendLine("items");
         foreach (var line in cart.Lines)
         {
             decimal subTotal = line.Product.Price * line.Quantity;
             body.AppendFormat(" {0} items of {1} Coast {2}", line.Quantity, line.Product.Name, subTotal);
         }
         body.AppendFormat("{0}", cart.TotalCoast()).AppendLine("-------")
         .AppendLine("Ship To " + details.Name)
         .AppendLine(details.Line_1).AppendLine(details.Line_2).AppendLine(details.Line_3)
         .AppendLine(details.State).AppendLine(details.Country).AppendLine(details.City)
         .AppendLine(details.Zip).AppendLine("--------")
         .AppendFormat(details.GiftWrap == true ? "Yes" : "No");
         MailMessage mm = new MailMessage(settings.mailFromAdress, settings.mailToAdress, "Some Text", body.ToString());
         if (settings.writeAsFie)
         {
             mm.BodyEncoding = Encoding.ASCII;
         }
         smtp.Send(mm);
     }
 }
コード例 #2
0
 public ViewResult Checkout(SheepingDetails details)
 {
     return(View(details));
 }