示例#1
0
        public ActionResult ModifyExpress()
        {
            if (Request.HttpMethod != "POST")
            {
                if (!AppData.IsManagerLogin)
                {
                    return(Redirect("/Manage/Error/1.html"));
                }
                if (PrivilegeBLL.HasNotPrivilege(AppData.SessionUserID, 1202))
                {
                    return(Redirect("/Manage/Error/2.html"));
                }

                Validation vld = new Validation(false);
                int        id  = vld.GetInt("id");

                ExpressBLL expressBLL = new ExpressBLL();
                ExpressObj expressObj = expressBLL.GetExpress(id);

                ViewBag.id   = id;
                ViewBag.name = expressObj.ExpressName;
                ViewBag.url  = expressObj.ExpressUrl;

                return(View());
            }
            else
            {
                if (!AppData.IsManagerLogin)
                {
                    return(Json(new { success = false, msg = "您未登录后台或会话已过期" }));
                }
                if (PrivilegeBLL.HasNotPrivilege(AppData.SessionUserID, 1202))
                {
                    return(Json(new { success = false, msg = "您没有执行该操作的权限" }));
                }

                ExpressBLL expressBLL = new ExpressBLL();

                Validation vld        = new Validation();
                int        id         = vld.GetInt("id");
                ExpressObj expressObj = expressBLL.GetExpress(id);
                expressObj.ExpressName = vld.Get("name", false);
                expressObj.ExpressUrl  = vld.Get("url");

                if (vld.HasError)
                {
                    return(Json(new { success = false, msg = "必须填写快递名称" }));
                }

                expressBLL.ModifyExpress(expressObj);

                return(Json(new { success = true }));
            }
        }
示例#2
0
        public ActionResult GetExpress()
        {
            Validation vld     = new Validation();
            int        express = vld.GetInt("id");

            ExpressBLL expressBLL = new ExpressBLL();
            dynamic    result;

            if (express == 0)
            {
                result = expressBLL.GetExpress();
            }
            else
            {
                result = expressBLL.GetExpress(express);
            }

            return(Json(new { success = true, data = result }));
        }
示例#3
0
        public ActionResult DeleteExpress()
        {
            if (!AppData.IsManagerLogin)
            {
                return(Json(new { success = false, msg = "您未登录后台或会话已过期" }));
            }
            if (PrivilegeBLL.HasNotPrivilege(AppData.SessionUserID, 1203))
            {
                return(Json(new { success = false, msg = "您没有执行该操作的权限" }));
            }

            ExpressBLL expressBLL = new ExpressBLL();

            Validation vld = new Validation();
            int        id  = vld.GetInt("id");

            if (id != 0)
            {
                expressBLL.DeleteExpress(id);
            }

            return(Json(new { success = true }));
        }
示例#4
0
        public ActionResult Product(int id)
        {
            ProductBLL productBLL                    = new ProductBLL();
            ProductObj productObj                    = productBLL.GetProduct(id);
            Dictionary <int, string> cates           = new Dictionary <int, string>();
            ProductCateObj           productCateObj  = productBLL.GetProductCateByCateID(productObj.CategoryID);
            IList <ProductCateObj>   productCateList = new List <ProductCateObj>();

            ViewBag.allCates = productBLL.GetProductCates();

            int total;

            productBLL.GetComments(id, 1, 1, out total);

            ViewBag.commentCount = total;
            productBLL.GetMessages(id, 1, 1, out total);
            ViewBag.messageCount = total;

            while (productCateObj != null)
            {
                productCateList.Add(productCateObj);
                productCateObj = productBLL.GetProductCateByCateID(productCateObj.ParentID);
            }
            StringBuilder sb = new StringBuilder();

            for (int i = productCateList.Count - 1; i >= 0; i--)
            {
                sb.Append("&gt;")
                .Append("<a href='/list/")
                .Append(productCateList[i].CategoryID)
                .Append(".html'>")
                .Append(productCateList[i].CategoryName)
                .Append("</a>");
            }
            ViewBag.current = new MvcHtmlString(sb.ToString());
            ViewBag.product = productObj;

            //int totalRecommends;
            //ViewBag.recommends = productBLL.GetProducts(0, null, 0, 0, -1, -1, 1, -1, 1, 10, out  totalRecommends);

            ExpressBLL expressBLL = new ExpressBLL();

            ViewBag.express = expressBLL.GetExpress();

            HttpCookie cookie = Request.Cookies["phistory"];

            if (cookie == null || string.IsNullOrEmpty(cookie.Value))
            {
                cookie             = new HttpCookie("phistory", id.ToString());
                cookie.Expires     = DateTime.Now.AddDays(30);
                ViewBag.recommends = productBLL.GetProducts(new List <int> {
                    id
                });
            }
            else
            {
                string[]    values = cookie.Value.Split(',');
                bool        flag   = false;
                IList <int> hst    = new List <int>();
                for (int i = 0; i < values.Length; i++)
                {
                    hst.Add(int.Parse(values[i]));
                    if (int.Parse(values[i]) == id)
                    {
                        flag = true;
                        break;
                    }
                }
                if (!flag)
                {
                    hst.Insert(0, id);
                    cookie.Value = "";
                    for (int i = 0; i < hst.Count && i < 10; i++)
                    {
                        if (i != 0)
                        {
                            cookie.Value += ",";
                        }
                        cookie.Value += hst[i].ToString();
                    }
                }
                ViewBag.recommends = productBLL.GetProducts(hst);

                cookie.Expires = DateTime.Now.AddDays(30);
            }
            Response.SetCookie(cookie);

            return(View());
        }