示例#1
0
 public ActionResult ListViewCart()
 {
     if ((int?)Session["UserID"] != null)
     {
         List <BillDetail> a = new List <BillDetail>();
         a = BillAction.ListCartDetail((int)Session["UserID"]);
         ViewBag.CountItem = BillAction.CountBill((int)Session["UserID"]);
         ViewBag.Total     = BillAction.ReBill((int)Session["UserID"]);
         if (a != null)
         {
             return(PartialView(a));
         }
         else
         {
             return(PartialView());
         }
     }
     else if (BillAction.CountBill((int)Session["UserID"]) == 0)
     {
         return(RedirectToAction("HomePage", "Home"));
     }
     else
     {
         return(RedirectToAction("Login", "Account"));
     }
 }
        public ActionResult OrderBill()
        {
            int    a        = (int)Session["UserID"];
            var    listcash = BillAction.ListCartDetail(a);
            var    detail   = listcash.FirstOrDefault();
            string text     = "";

            foreach (var item in listcash)
            {
                text += item.Book.Name + "<br/>" + item.Price + "\n" + item.Count;
            }
            CashAction.Order(a);
            string content = System.IO.File.ReadAllText(Server.MapPath("~/client/template/neworder.html"));

            Session["alert"] = "ok";
            content          = content.Replace("{{Name}}", "sadsada");
            content          = content.Replace("{{product}}", text);
            content          = content.Replace("{{Content}}", "*****@*****.**");
            content          = content.Replace("{{totalcost}}", Convert.ToString(detail.Bill.TotalCost));
            var toEmail = ConfigurationManager.AppSettings["ToEmailAddress"].ToString();

            new MailHelper().SendMail("*****@*****.**", "Đơn Đặt Hàng", content);
            new MailHelper().SendMail(toEmail, "Đơn Đặt Hàng", content);
            return(RedirectToAction("ViewCart", "Cart"));
        }
示例#3
0
        public ActionResult ViewCart()
        {
            ViewBag.BookTop = BookAction.AddSachTop5ToDb();
            if (TempData["Alert"] != null)
            {
                ViewBag.Alert = TempData["Alert"].ToString();
            }
            if (Session["UserName"] != null && (int)Session["Role"] == 2)
            {
                int AccountId = (int)Session["UserID"];
                if (Session["UserID"] == null)
                {
                    return(RedirectToAction("Login", "Account"));
                }
                var listCart = BillAction.ListCartDetail(AccountId);

                if (listCart != null)
                {
                    ViewBag.ListCart = listCart;
                    ViewBag.Detail   = listCart.FirstOrDefault();
                }
                return(View());
            }
            return(RedirectToAction("Login", "Account"));
        }
 public ActionResult OrderBill()
 {
     try
     {
         int a        = (int)Session["UserID"];
         var listcash = BillAction.ListCartDetail(a);
         var detail   = listcash.FirstOrDefault();
         CashAction.Order(a);
         return(RedirectToAction("ViewCart", "Cart"));
     } catch {
         return(RedirectToAction("ViewCart", "Cart"));
     }
 }
        public ActionResult ViewCart()
        {
            if (Session["UserName"] != null)
            {
                int AccountId = (int)Session["UserID"];
                var listCart  = BillAction.ListCartDetail(AccountId);

                if (listCart != null)
                {
                    ViewBag.ListCart = listCart;
                    ViewBag.Detail   = listCart.FirstOrDefault();
                }
                return(View());
            }
            return(RedirectToAction("Index", "Book"));
        }