Exemple #1
0
        // GET: Details
        public ActionResult Index(string phoneID)
        {
            PhoneDAO dao   = new PhoneDAO();
            Phone    phone = dao.GetPhone(phoneID);

            ViewData["PHONE"] = phone;
            return(View());
        }
        public ActionResult ViewUpdate(string phoneID)
        {
            SupplierDAO   dao      = new SupplierDAO();
            PhotoPhoneDAO daoPhoto = new PhotoPhoneDAO();
            PhoneDAO      daoPhone = new PhoneDAO();

            ViewData["SUPPLIER_LIST"] = dao.GetAllSupplier();
            ViewData["UPDATE"]        = daoPhone.GetPhone(phoneID);
            ViewData["PHOTO"]         = daoPhoto.GetPhotoOfPhone(phoneID);
            return(View());
        }
        public JsonResult CheckDupMobileID(string phoneID)
        {
            System.Threading.Thread.Sleep(1500);
            PhoneDAO dao   = new PhoneDAO();
            Phone    phone = dao.GetPhone(phoneID);

            if (phone != null)
            {
                return(Json(1));
            }
            else
            {
                return(Json(0));
            }
        }
        public JsonResult AddToCartWithValue(string phoneID, int value)
        {
            PhoneDAO dao  = new PhoneDAO();
            Phone    p    = dao.GetPhone(phoneID);
            CartObj  cart = (CartObj)Session["CART"];

            if (cart == null)
            {
                cart = new CartObj();
            }
            cart.AddToCart(phoneID, value);
            Session["CART"] = cart;
            List <dynamic> x = new List <dynamic>();

            x.Add(cart.cart.Count);
            x.Add(cart.total);
            x.Add(p.quantity - cart.cart[p]);
            return(Json(x));
        }
        public JsonResult UpdateCart(string phoneID, int value)
        {
            PhoneDAO dao   = new PhoneDAO();
            Phone    phone = dao.GetPhone(phoneID);
            CartObj  cart  = (CartObj)Session["CART"];

            if (cart == null)
            {
                cart = new CartObj();
            }
            cart.UpdateCart(phoneID, value);
            Session["CART"] = cart;
            List <dynamic> x = new List <dynamic>();

            x.Add(cart.cart.Count);
            x.Add(cart.total);
            x.Add(cart.cart[phone] * phone.price);
            return(Json(x));
        }