Esempio n. 1
0
        /*
         * public ActionResult Add()
         * {
         *  UserResBody currResBody = new UserResBody();
         *  foreach (UserResBody item in base._userResBody)
         *  {
         *      if (item.res_path.Equals("0,1,101,192,"))
         *      {
         *          currResBody = item;
         *          break;
         *      }
         *  }
         *
         *  ViewData["currResBody"] = currResBody;//当前菜单
         *  string position = "";
         *  ViewData["pageTitle"] = base.FormatPageTile(currResBody, ref position);
         *  ViewData["position"] = position;//页面位置
         *
         *  return View();
         * }
         * */
        #endregion

        #region Items
        public ActionResult Items()
        {
            UserResBody currResBody = new UserResBody();

            foreach (UserResBody item in base._userResBody)
            {
                if (item.res_path.Equals("0,1,105,144,202,"))
                {
                    currResBody = item;
                    break;
                }
            }

            HasPermission(currResBody.res_id);

            ViewData["currResBody"] = currResBody;//当前菜单
            string position = "";

            ViewData["pageTitle"] = base.FormatPageTile(currResBody, ref position);
            ViewData["position"]  = position;//页面位置

            int    posId = DoRequest.GetQueryInt("posid");
            string q     = DoRequest.GetQueryString("q");

            List <RecommendListInfo> infoList = null;
            var resp = GetRecommendItemByRpId.Do(posId);

            if (resp == null || resp.Body == null)
            {
                infoList = new List <RecommendListInfo>();
            }
            else
            {
                infoList = resp.Body.item_list;
            }

            ViewData["infoList"] = infoList;

            return(View());
        }
Esempio n. 2
0
        public ActionResult PostItems()
        {
            int posId  = DoRequest.GetFormInt("posID");
            int listId = DoRequest.GetFormInt("ListID");

            int    ristyle  = DoRequest.GetFormInt("stype");
            string rivalue  = DoRequest.GetFormString("proid");
            string gtype    = DoRequest.GetFormString("gtype");
            string protype  = DoRequest.GetFormString("protype");
            string subject  = DoRequest.GetFormString("subject");
            string brand    = DoRequest.GetFormString("brand");
            string url      = DoRequest.GetFormString("url").Trim();
            string iconname = DoRequest.GetFormString("iconname");

            string   sdate     = DoRequest.GetFormString("sdate").Trim();
            int      shours    = DoRequest.GetFormInt("shours");
            int      sminutes  = DoRequest.GetFormInt("sminutes");
            DateTime startDate = Utils.IsDateString(sdate) ? DateTime.Parse(sdate + " " + shours + ":" + sminutes + ":00") : DateTime.Now;

            string   edate    = DoRequest.GetFormString("edate").Trim();
            int      ehours   = DoRequest.GetFormInt("ehours");
            int      eminutes = DoRequest.GetFormInt("eminutes");
            DateTime endDate  = Utils.IsDateString(edate) ? DateTime.Parse(edate + " " + ehours + ":" + eminutes + ":59") : DateTime.Now.AddDays(7);

            string image   = DoRequest.GetFormString("image");
            string summary = DoRequest.GetFormString("summary");

            int plat = DoRequest.GetFormInt("useplat");

            if (plat == 4)
            {
                plat = 6;
            }
            string imgsrc = "";

            if (ristyle == 1)
            {
                ProductInfo product = new ProductInfo();
                var         respro  = GetProductInfo.Do(Utils.StrToInt(rivalue, 0));
                if (respro != null && respro.Body != null)
                {
                    product = respro.Body;
                }
                imgsrc = product.img_src;

                if (product.product_id < 1)
                {
                    return(Json(new { error = true, message = "商品不存在" }));
                }
            }

            if ((ristyle == 4 || ristyle == 5) && HasChinese(rivalue))
            {
                return(Json(new { error = true, message = "URL不能含中文!" }));
            }

            if (HasChinese(url))
            {
                return(Json(new { error = true, message = "URL不能含中文!" }));
            }

            if (ristyle == 2)
            {
                rivalue = protype;
                if (rivalue.Equals("") || rivalue == null)
                {
                    return(Json(new { error = true, message = "请选择分类!" }));
                }
            }


            List <RecommendListInfo> items = new List <RecommendListInfo>();
            var resrel = GetRecommendItemByRpId.Do(posId);

            if (resrel != null && resrel.Body != null && resrel.Body.item_list != null)
            {
                items = resrel.Body.item_list;
            }
            List <int> liids = new List <int>();

            foreach (RecommendListInfo em in items)
            {
                liids.Add(em.ri_id);
            }

            RecommendListInfo listInfo = items.Find(delegate(RecommendListInfo em)
            {
                return(em.ri_id == listId);
            });

            if (listInfo == null)
            {
                listInfo = new RecommendListInfo();
            }

            RecommendListInfo listInfo2 = items.Find(delegate(RecommendListInfo em)
            {
                return(em.ri_value.Equals(rivalue));
            });

            if (listInfo2 == null)
            {
                listInfo2 = new RecommendListInfo();
            }

            if (!liids.Contains(listId) && rivalue.Equals(listInfo2.ri_value) && (listInfo.ri_id > 0) && ((startDate >= DateTime.Parse(listInfo.start_time) && startDate <= DateTime.Parse(listInfo.end_time)) || (endDate >= DateTime.Parse(listInfo.start_time) && endDate <= DateTime.Parse(listInfo.end_time)) || (startDate <= DateTime.Parse(listInfo.start_time) && endDate >= DateTime.Parse(listInfo.end_time))))
            {
                return(Json(new { error = true, message = "该推荐项在同期同位置已被推荐" }));
            }

            #region Checking
            if (subject.Length <= 0)
            {
                return(Json(new { error = true, message = "推荐标题不能为空" }));
            }

            if (image.Length > 300)
            {
                return(Json(new { error = true, message = "图标地址不能超过300个字符" }));
            }
            if (summary.Length > 600)
            {
                return(Json(new { error = true, message = "简介不能超过600个字符" }));
            }
            #endregion

            listInfo.ri_id   = listId;
            listInfo.rp_id   = posId;
            listInfo.ri_type = ristyle;

            if (ristyle == 5 && plat < 4)
            {
                listInfo.ri_value = gtype;
                listInfo.page_src = rivalue;
            }
            else
            {
                listInfo.ri_value = rivalue;
                listInfo.page_src = url;
            }

            if (ristyle == 1)
            {
                listInfo.product_id = Utils.StrToInt(rivalue, 0);
            }
            else
            {
                listInfo.product_id = 0;
            }

            listInfo.ri_subject    = subject;
            listInfo.product_brand = brand;
            listInfo.ri_summary    = summary;
            listInfo.start_time    = startDate.ToString("yyyy-MM-dd HH:mm:ss");
            listInfo.end_time      = endDate.ToString("yyyy-MM-dd HH:mm:ss");

            if (plat < 0 || plat > 7)
            {
                return(Json(new { error = true, message = "显示平台选择不规范" }));
            }

            listInfo.use_plat = plat;

            if (!string.IsNullOrEmpty(image))
            {
                listInfo.img_src = image;
            }
            else
            {
                listInfo.img_src = imgsrc;
            }

            if (listInfo.product_brand == null)
            {
                listInfo.product_brand = "";
            }

            listInfo.icon_name = iconname;

            int returnValue = -1;
            var res         = OpRecommendItems.Do(listInfo);
            if (res != null && res.Header != null && res.Header.Result != null && res.Header.Result.Code != null)
            {
                returnValue = Utils.StrToInt(res.Header.Result.Code, -1);
            }
            #region 判断是否操作成功
            string msgText = "";
            switch (returnValue)
            {
            case 0:
                msgText = "操作成功 ^_^";
                break;

            case -1:
                msgText = "操作失败";
                break;

            default:
                msgText = "操作失败";
                break;
            }
            #endregion

            return(Json(new { error = returnValue == 0 ? false : true, message = msgText }));
        }