Пример #1
0
        public ActionResult ThanhToan(Order model)
        {
            if (ModelState.IsValid)
            {
                model.CreateDate = DateTime.Now;
                SetViewBag(model.Payment);
                model.Status = 2;
                var accSession = (AccLogin)Session[Account_Session];
                model.CusomerID = accSession.AccID;
                decimal total = 0;

                int id      = new OrderDAO().Insert(model);
                var cart    = (List <CartItem>)Session[CartSession];
                var teoInfo = new OrderInfoDAO();
                foreach (var item in cart)
                {
                    var orderInfo = new OrderInfo();
                    orderInfo.FoodID   = item.Food.ID;
                    orderInfo.OrderID  = id;
                    orderInfo.Price    = item.Food.Price;
                    orderInfo.Quantity = item.Quantity;
                    teoInfo.Insert(orderInfo);
                    total += (item.Food.Price.Value * item.Quantity);
                }
                new OrderDAO().UpdateTotalPrice(id, total);

                string content        = System.IO.File.ReadAllText(Server.MapPath("~/Content/temlate/neworder.html"));
                string diaChiDayDayDu = model.Other + ", " + model.Town + ", " + model.State;
                content = content.Replace("{{CustomerName}}", model.FirstName + " " + model.LastName);
                content = content.Replace("{{Phone}}", model.Phone);
                content = content.Replace("{{Email}}", model.Email);
                content = content.Replace("{{Address}}", diaChiDayDayDu);
                content = content.Replace("{{Total}}", total.ToString("N0"));
                new MailHelper().SendMail(model.Email, "Đơn hàng từ quán cà phê Bảo Bảo", content);
                Session[CartSession] = null;

                return(Redirect("/thanh-toan-thanh-cong"));
            }
            SetViewBag();
            return(View(model));
        }
Пример #2
0
 private OrderService()
 {
     // _daoManager = ServiceConfig.GetInstance().DaoManager;
     //_orderDao = _daoManager.GetDao(typeof(IOrder)) as IOrder;
     _orderDao = new OrderInfoDAO();
 }