示例#1
0
        public ActionResult checkout(string shipName, string shipEmail, string shipMobile, string shipAddress)
        {
            var order = new Order();

            order.CreateDate  = DateTime.Now;
            order.ShipAddress = shipAddress;
            order.ShipEmail   = shipEmail;
            order.ShipName    = shipName;
            order.ShipMoblie  = shipMobile;
            try
            {
                var     id        = new OderDao().Insert(order);
                var     cart      = (List <CartItem>)Session[CartSession];
                var     detailDao = new OderDetailDao();
                decimal total     = 0;
                foreach (var item in cart)
                {
                    var orderDetail = new OderDetail();
                    orderDetail.ProductID = item.Pro.ID;
                    orderDetail.OrderID   = id;
                    orderDetail.Price     = item.Pro.Price;
                    orderDetail.Quantity  = item.Quantity;
                    detailDao.Insert(orderDetail);
                    total += (item.Pro.Price.GetValueOrDefault(0) * item.Quantity);
                }
            }
            catch (Exception)
            {
                return(Redirect("/loi-thanh-toan"));
            }
            return(Redirect("/hoan-thanh"));
        }
        // GET: Admin/OrderDetail
        public ActionResult Index(int page = 1, int pageSize = 10)
        {
            var dao   = new OderDetailDao();
            var model = dao.ListAllPaging(page, pageSize);

            return(View(model));
        }
示例#3
0
        public ActionResult Payment(string name, string mobile, string address, string email)
        {
            //  tạo đối tượng Oder
            var oder = new Order();

            oder.ShipName    = name;
            oder.ShipMobie   = mobile;
            oder.ShipAddress = address;
            oder.ShipEmail   = email;
            oder.CreateDate  = DateTime.Now;
            try
            {
                var     oderid     = new OderDao().InsertOder(oder);
                var     cart       = (List <CarItem>)Session[CommonConstants.CartSession];
                var     oderDetail = new OderDetail();
                decimal total      = 0;
                foreach (var item in cart)
                {
                    var product = item.Product;
                    oderDetail.ProductID = product.ID;
                    oderDetail.OderID    = oderid;
                    oderDetail.Price     = product.Price;
                    oderDetail.Quantity  = item.Quantity;
                    var result = new OderDetailDao().Insert(oderDetail);
                    total += (item.Product.Price.GetValueOrDefault(0) * item.Quantity);
                }
                string content = System.IO.File.ReadAllText(Server.MapPath("~/assets/client/template/newOrder.html"));
                content = content.Replace("{{CustomerName}}", name);
                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();
                // Gữi  email xác  nhận  đã đặt mua  đến khách hàng
                new MailHelper().SendMail(email, "Đơn  đặt hàng của bạn trên OnlineShop", content);
                // Gữi email  thông báo  tới  quản trị  có đơn hàng
                new MailHelper().SendMail(toEmail, "Đơn  đặt hàng mới của khách hàng", content);
            }
            catch (Exception)
            {
                // ghi log
                return(Redirect("/loi-thanh-toan"));
            }

            return(Redirect("/hoan-thanh"));
        }
示例#4
0
        public ActionResult checkoutTempleate(string shipName, string shipEmail, string shipMobile, string shipAddress)
        {
            var order = new Order();

            order.CreateDate  = DateTime.Now;
            order.ShipAddress = shipAddress;
            order.ShipEmail   = shipEmail;
            order.ShipName    = shipName;
            order.ShipMoblie  = shipMobile;
            try
            {
                var     id        = new OderDao().Insert(order);
                var     cart      = (List <CartItem>)Session[CartSession];
                var     detailDao = new OderDetailDao();
                decimal total     = 0;
                foreach (var item in cart)
                {
                    var orderDetail = new OderDetail();
                    orderDetail.ProductID = item.Pro.ID;
                    orderDetail.OrderID   = id;
                    orderDetail.Price     = item.Pro.Price;
                    orderDetail.Quantity  = item.Quantity;
                    detailDao.Insert(orderDetail);
                    total += (item.Pro.Price.GetValueOrDefault(0) * item.Quantity);
                }
                string content = System.IO.File.ReadAllText(Server.MapPath("~/Content/client/template/neworder.html"));

                content = content.Replace("{{CustomerName}}", shipName);
                content = content.Replace("{{Phone}}", shipMobile);
                content = content.Replace("{{Email}}", shipEmail);
                content = content.Replace("{{Address}}", shipAddress);
                content = content.Replace("{{Total}}", total.ToString("N0"));
                var toEmail = ConfigurationManager.AppSettings["ToEmailAddress"].ToString();

                new MailHelper().SendMail(shipEmail, "Order from", content);
                new MailHelper().SendMail(toEmail, "Order from", content);
            }
            catch (Exception)
            {
                return(Redirect("/loi-thanh-toan"));
            }
            return(Redirect("/hoan-thanh"));
        }