Exemplo n.º 1
0
        /// <summary>
        /// 修改状态
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public ActionResult UpdateStatus(int id)
        {
            SWfsStyleMatchSpecial model = new SWfsStyleMatchSpecial();

            model = styleService.GetModel(id);
            if (model.Position == 1)
            {
                model.Position = 2;
            }
            else
            {
                model.Position = 1;
            }
            model.ID = id;
            bool rs = styleService.Update(model);

            return(Json(new { result = rs ? 1 : -1, msg = rs ? "修改成功" : "修改失败" }, JsonRequestBehavior.AllowGet));
        }
Exemplo n.º 2
0
        public ActionResult CarouselManage(string act, int id = 0)
        {
            SWfsStyleMatchSpecial model = new SWfsStyleMatchSpecial();

            ViewBag.Act = act;
            switch (act)
            {
            case "add":    //新建
                model.StartTime = Convert.ToDateTime("1900-1-1");
                model.EndTime   = Convert.ToDateTime("1900-1-1");
                return(View("/Areas/Shangpin/Views/Style/StyleCarouselManage.cshtml", model));

            case "edit":    //修改
                model = styleService.GetModel(id);
                return(View("/Areas/Shangpin/Views/Style/StyleCarouselManage.cshtml", model));
            }
            return(View());
        }
Exemplo n.º 3
0
        public JsonResult ManageMatchSpecial()
        {
            string        imgSize             = AppSettingManager.AppSettings["MatchSpecialPic"].ToString();
            string        imgTyle             = AppSettingManager.AppSettings["MatchSpecialPicType"].ToString();
            CommonService commonService       = new CommonService();
            Dictionary <string, string> rsPic = new Dictionary <string, string>();
            int    id                   = Convert.ToInt32(Request["ID"]);
            string position             = Request["Position"];
            string picUrl               = Request["PicUrl"];
            SWfsStyleMatchSpecial model = new SWfsStyleMatchSpecial();

            if (id != 0)
            {
                model = styleService.GetModel(id);
                if (null == model)
                {
                    return(Json(new { reslut = -1, msg = "记录不存在" }));
                }
            }
            model.SpecialName = Request["SpecialName"];

            if (!string.IsNullOrEmpty(picUrl) && !picUrl.StartsWith("http://"))
            {
                return(Json(new { reslut = -1, msg = "图片链接地址格式不正确" }));
            }
            else
            {
                model.PicUrl = picUrl;
            }
            model.StartTime    = Convert.ToDateTime(Request["StartTime"]);
            model.EndTime      = Convert.ToDateTime(Request["EndTime"]);
            model.UpdateDate   = DateTime.Now;
            model.UpdateUserId = PresentationHelper.GetPassport().UserName;
            model.Type         = 1;
            if (id == 0) //创建
            {
                model.Position = Convert.ToInt16(position);
                if (null != Request.Files["PicFile"] && Request.Files["PicFile"].ContentLength > 0)
                {
                    rsPic = commonService.PostImg(Request.Files["PicFile"], imgSize, imgTyle);
                    if (rsPic.Keys.Contains("error"))
                    {
                        return(Json(new { reslut = -1, msg = rsPic.Values.FirstOrDefault() }, "text/plain", Encoding.UTF8));
                    }
                    if (rsPic.Keys.Contains("success"))
                    {
                        model.PicNo = rsPic["success"];
                    }
                }
                else
                {
                    return(Json(new { reslut = -1, msg = "请选择图片" }));
                }
                try
                {
                    model.CreateUserId = PresentationHelper.GetPassport().UserName;
                    model.CreateDate   = DateTime.Now;
                    styleService.Add(model);
                    return(Json(new { reslut = 1, msg = "添加成功" }, "text/plain", Encoding.UTF8));
                }
                catch (Exception e)
                {
                    return(Json(new { reslut = 1, msg = e.Message }));
                }
            }
            else //修改
            {
                if (model.Position.ToString() != position) //说明修改了广告位置
                {
                    if (null == Request.Files["PicFile"] || Request.Files["PicFile"].ContentLength <= 0)
                    {
                        return(Json(new { reslut = -1, msg = "修改广告位置后请重新上传广告图" }));
                    }
                }
                model.Position = Convert.ToInt16(position);
                if (null != Request.Files["PicFile"] && Request.Files["PicFile"].ContentLength > 0)
                {
                    rsPic = commonService.PostImg(Request.Files["PicFile"], imgSize, imgTyle);
                    if (rsPic.Keys.Contains("error"))
                    {
                        return(Json(new { reslut = -1, msg = rsPic.Values.FirstOrDefault() }, "text/plain", Encoding.UTF8));
                    }
                    if (rsPic.Keys.Contains("success"))
                    {
                        model.PicNo = rsPic["success"];
                    }
                }
                model.ID = id;
                bool rs = styleService.Update(model);
                return(Json(new { reslut = rs ? 1 : -1, msg = rs ? "修改成功" : "修改失败" }, "text/plain", Encoding.UTF8));
            }
        }
Exemplo n.º 4
0
 /// <summary>
 /// 修改
 /// </summary>
 /// <param name="model"></param>
 /// <returns></returns>
 public bool Update(SWfsStyleMatchSpecial model)
 {
     return(DapperUtil.Update(model));
 }
Exemplo n.º 5
0
 /// <summary>
 /// 添加
 /// </summary>
 /// <param name="model"></param>
 /// <returns></returns>
 public int Add(SWfsStyleMatchSpecial model)
 {
     return(DapperUtil.Insert(model));
 }