Exemplo n.º 1
0
        public JsonResult ChangeStatus(string pId, string pStatus, string pAction)
        {
            if (string.IsNullOrEmpty(pId) || string.IsNullOrEmpty(pStatus))
            {
                return(Json(new { status = false, message = "Input is wrong" }, JsonRequestBehavior.AllowGet));
            }
            int productId = 0, productStatus = 0;

            int.TryParse(pId, out productId); int.TryParse(pStatus, out productStatus);
            if (productId <= 0)
            {
                return(Json(new { status = false, message = "Not found." }, JsonRequestBehavior.AllowGet));
            }
            ProductDAL db            = new ProductDAL();
            int        executeStatus = 0;

            if (pAction == "isnew")
            {
                executeStatus = db.ChangeIsNew(productId, productStatus);
            }
            else if (pAction == "ishome")
            {
                executeStatus = db.ChangeIsHome(productId, productStatus);
            }
            else if (pAction == "ishot")
            {
                executeStatus = db.ChangeIsHot(productId, productStatus);
            }
            if (executeStatus == 1)
            {
                return(Json(new { status = true }, JsonRequestBehavior.AllowGet));
            }
            return(Json(new { status = false }, JsonRequestBehavior.AllowGet));
        }