コード例 #1
0
 public bool Insert(m_order_bill order)
 {
     try
     {
         db.m_order_bill.Add(order);
         db.SaveChanges();
         return(true);
     }
     catch
     {
         return(false);
     }
 }
コード例 #2
0
        public ActionResult Payment(string shipname, string mobile, string address, string email)
        {
            var order = new m_product_bill();

            order.CreatedDate = DateTime.Now;
            order.ShipAddress = address;
            order.shipPhone   = mobile;
            order.ShipName    = shipname;
            order.ShipEmail   = email;
            if (Session[commonConst.user_client] != null)
            {
                userLogin a = Session[commonConst.user_client] as userLogin;
                order.CustomerID = Convert.ToInt64(a.userID);
            }
            try
            {
                var     id        = new OrderDao().Insert(order);
                var     cart      = (List <CartItem>)Session[cartSession];
                var     detailDao = new OrderBillDao();
                decimal total     = 0;
                foreach (var item in cart)
                {
                    var orderDetail = new m_order_bill();
                    orderDetail.ProductId   = item.Product.ID;
                    orderDetail.ProductBill = id;
                    orderDetail.Price       = item.Product.Price;
                    orderDetail.Quantity    = item.Quantity;
                    detailDao.Insert(orderDetail);
                    total += (item.Product.Price.GetValueOrDefault(0) * item.Quantity);
                }
                Session["cartSession"] = null;
                //string content = System.IO.File.ReadAllText(Server.MapPath("~/Assets/client/template/neworder.html"));
                //content = content.Replace("{{CustomerName}}", shipname);
                //content = content.Replace("{{Phone}}", mobile);
                //content = content.Replace("{{Email}}", email);
                //content = content.Replace("{{Address}}", address);
                //content = content.Replace("{{Total}}", total.ToString("N0"));
                //var toEmail = ConfigurationManager.AppSettings["ToEmailAddress"].ToString();

                //new MailHelper().SendMail(email, "Đơn hàng mới từ OnlineShop", content);
                //new MailHelper().SendMail(toEmail, "Đơn hàng mới từ OnlineShop", content);
            }
            catch (Exception ex)
            {
                return(Redirect("/loi-thanh-toan"));
            }
            return(Redirect("/hoan-thanh"));
        }