private void CheckPurchasedList(PurchasedData data, int index) { if (data.list.Count > index) { UiShopItem.Purchased(data.list[index].sku, data.list[index].token, () => CheckPurchasedList(data, index + 1)); } else { Game.Instance.OpenPopup <Popup_Confirm>().Setup(111062, true, false, null); } }
public ActionResult PurchasedMessage() { int count = db.Carts.Count(); var temps = db.Carts.ToList(); string email = ""; if (Session["user"] != null) { email = Session["tempEmail"].ToString(); foreach (var temp in temps) { db.PurchasedDatas.Add(new PurchasedData() { ID = 1, ProductID = temp.ProductID, Price = temp.Price, Category = temp.Category, Color = temp.Color, Brand = temp.Brand, Entery_Date = DateTime.Now.ToShortDateString(), ChooseImage = temp.ChooseImage, Email = email }); } int flag = db.SaveChanges(); if (flag > 0) { db.Database.ExecuteSqlCommand("TRUNCATE TABLE [Cart]"); // var records = db.Carts.Where(a => a.Email== email).ToList(); //foreach (var item in records) //{ // db.Carts.Remove(item); //} //db.SaveChanges(); string tempemail = Session["tempEmail"].ToString(); List <PurchasedData> outputList = db.PurchasedDatas.Where(t => t.Email == tempemail).ToList(); List <PurchasedData> inputList = new List <PurchasedData>(); foreach (var item in outputList) { PurchasedData outputItem = new PurchasedData(item); inputList.Add(outputItem); } //string file = @"D:\DownloadFile\Receipt.txt"; //TextWriter tw = new StreamWriter(file); //foreach (var item in inputList) //{ // tw.WriteLine(item.ToString()); //} //tw.Close(); MailMessage mail = new MailMessage(); mail.From = new MailAddress("*****@*****.**", "Farah's Shopping Cart"); mail.To.Add(tempemail); mail.IsBodyHtml = true; mail.Subject = "Confirm Purchased Message"; mail.Body = Session["UserFirstName"].ToString() + " Thank You for Purchasing."; System.Net.Mail.Attachment attachment; MemoryStream workStream = new MemoryStream(); attachment = new System.Net.Mail.Attachment(workStream, "txt"); attachment.ContentDisposition.FileName = "Receipt " + DateTime.Now.ToString("yyyy MM dd") + ".txt"; mail.Attachments.Add(attachment); mail.Priority = MailPriority.High; SmtpClient smtp = new SmtpClient("smtp.gmail.com", 587); //smtp.UseDefaultCredentials = true; smtp.Credentials = new System.Net.NetworkCredential("*****@*****.**", "get-lost"); smtp.EnableSsl = true; //smtp.DeliveryMethod = SmtpDeliveryMethod.Network; smtp.Send(mail); return(View()); } return(View("Error")); } return(View("Error")); //return View(); }