Beispiel #1
0
        public ActionResult Create(topup_card topup_Card)
        {
            try
            {
                for (int i = 0; i < topup_Card.amount; i++)
                {
                    using (OrderSystemEntities2 db = new OrderSystemEntities2())
                    {
                        //count current index of total rơ in table, +1 for new record
                        int    countNum = db.topup_card.Count() + 1;
                        int    uID      = (Int32)(Session["id"]);
                        string seri     = Get8CharacterRandomString();
                        string code     = Get8CharacterRandomString();
                        topup_Card.serial_number = countNum + seri;
                        topup_Card.code          = countNum + code;
                        topup_Card.create_time   = DateTime.Now;
                        topup_Card.creator       = uID;
                        db.topup_card.Add(topup_Card);
                        db.SaveChanges();
                    }
                }

                return(RedirectToAction("Index"));
            }
            catch
            {
                return(View());
            }
        }
Beispiel #2
0
        private void SendActivationEmail(user user, topup_card card)
        {
            using (MailMessage mm = new MailMessage("*****@*****.**", user.email))
            {
                mm.Subject = "Nạp Tiền Thành Công";
                string body = "<div style='font - family: Segoe UI; margin: 0; color: #707070;font-size:16px;'>";
                body += "<div style='max - width:800px; width: 100 %; margin: 0 auto; '>";
                body += "<img style='width: 100 % ' src='https://i.pinimg.com/564x/f9/98/86/f99886a97ba4e7b0aa4d8b33e00b060c.jpg' />";
                body += "<div style='padding: 1.5rem; color: #707070;'>";
                body += " <h3 style='color:#069B4F; font-size:24px;'>Nạp tiền thành công</h3>";
                body += "Xin chào " + user.name + ",";
                body += "<br /><br />Bạn đã nạp thành công " + card.value + " nghìn đồng từ thẻ nạp có số series: " + card.serial_number;


                body         += "<br /><br />Cảm ơn bạn đã sử dụng dịch vụ và chúc bạn một ngày tốt lành !";
                mm.Body       = body;
                mm.IsBodyHtml = true;
                SmtpClient smtp = new SmtpClient();
                smtp.Host      = "smtp.gmail.com";
                smtp.EnableSsl = true;
                NetworkCredential NetworkCred = new NetworkCredential("*****@*****.**", "anhdaica1");
                smtp.UseDefaultCredentials = false;
                smtp.Credentials           = NetworkCred;
                smtp.Port = 587;
                smtp.Send(mm);
            }
        }