Beispiel #1
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"));
        }
 public ActionResult Edit(m_product_bill acc)
 {
     if (ModelState.IsValid)
     {
         var dao    = new ProductBillDao();
         var result = dao.update(acc);
         if (result)
         {
             setAleart("Sửa tài khoản thành công !", "Success");
             return(RedirectToAction("Index", "Account"));
         }
         else
         {
             ModelState.AddModelError("", "Cập nhập không thành công");
         }
     }
     return(View());
 }
Beispiel #3
0
 public ActionResult Create(m_product_bill user)
 {
     if (ModelState.IsValid)
     {
         var  dao = new ProductBillDao();
         long id  = dao.Insert(user);
         if (id > 0)
         {
             setAleart("Thêm tài khoản thành công !", "Success");
             return(RedirectToAction("Index", "ProductBill"));
         }
         else
         {
             ModelState.AddModelError("", "Thêm user khong thành công");
         }
     }
     return(View());
 }
Beispiel #4
0
 public bool update(m_product_bill ennity)
 {
     try
     {
         var user = db.m_product_bill.Find(ennity.Id);
         user.CreatedDate = ennity.CreatedDate;
         user.CustomerID  = ennity.CustomerID;
         user.shipPhone   = ennity.shipPhone;
         user.ShipAddress = ennity.ShipAddress;
         user.ShipEmail   = ennity.ShipEmail;
         user.ShipName    = ennity.ShipName;
         user.status_b    = ennity.status_b;
         db.SaveChanges();
         return(true);
     }
     catch (Exception)
     {
         return(false);
     }
 }
 public long Insert(m_product_bill order)
 {
     db.m_product_bill.Add(order);
     db.SaveChanges();
     return(order.Id);
 }
Beispiel #6
0
 public long Insert(m_product_bill login)
 {
     db.m_product_bill.Add(login);
     db.SaveChanges();
     return(login.Id);
 }