Beispiel #1
0
        public ActionResult FeaturedEventAdd(string act, string fId = "", string channelNo = "", string channelName = "")
        {
            SWfsSubjectFeaturedEvents model = new SWfsSubjectFeaturedEvents();

            ViewBag.Act = act;
            SWfsChannelService service = new SWfsChannelService();

            //修改
            if (!string.IsNullOrEmpty(act) && !string.IsNullOrEmpty(fId.ToString()) && act == "edit")
            {
                model = service.GetFeatureEventInfo(Convert.ToInt32(fId));
            }
            //删除
            if (!string.IsNullOrEmpty(act) && !string.IsNullOrEmpty(fId.ToString()) && act.Equals("del"))
            {
                service.DeleteFeatureEventById(Convert.ToInt32(fId));
                return(Redirect("/outlet/channel/FeaturedEventsList?channel=" + channelNo + "&channelName=" + channelName));
            }
            return(View(model));
        }
 //修改频道主推活动
 public void Update(SWfsSubjectFeaturedEvents model)
 {
     DapperUtil.Update <SWfsSubjectFeaturedEvents>(model);
 }
 //添加频道主推活动
 public void Insert(SWfsSubjectFeaturedEvents model)
 {
     DapperUtil.Insert <SWfsSubjectFeaturedEvents>(model);
 }
        //根据id获取频道主推活动信息
        public SWfsSubjectFeaturedEvents GetFeatureEventInfo(int iD)
        {
            SWfsSubjectFeaturedEvents model = DapperUtil.Query <SWfsSubjectFeaturedEvents>("ComBeziWfs_SWfsSubject_GetChannelFeaturedEventByID", new { ID = iD }).FirstOrDefault();

            return(model);
        }
Beispiel #5
0
        public ActionResult FeaturedEventAdd()
        {
            CommonService               commonService = new CommonService();
            SWfsChannelService          service       = new SWfsChannelService();
            Dictionary <string, string> rsPic         = new Dictionary <string, string>();
            DateTime showDate  = Convert.ToDateTime(Request.Params["showDate"]);
            int      location  = Convert.ToInt32(Request.Params["loc"]);
            string   subjectNo = Request.Params["subjectNo"];
            string   channelNo = Request.Form["ChannelNo"];

            if (subjectNo.IndexOf(',') > 0)
            {
                subjectNo = subjectNo.Substring(0, subjectNo.IndexOf(','));
            }
            string spreadPicture = "";
            //判断是修改还是写入
            int ID = 0;

            if (Request.Form["ID"] != null)
            {
                ID = int.Parse(Request.Form["ID"]);
            }
            #region 写入前数据验证
            //根据活动位置和时间获取频道主推活动信息列表
            List <SWfsSubjectFeaturedEvents> sfeList = service.GetFeatureEventsByDateShow(channelNo, showDate, location);

            //获取一条活动信息
            SubjectInfo subjectInfo = service.GetSubjectInfoBySubjectNo(subjectNo);

            if (subjectInfo != null)
            {
                if (subjectInfo.Status == 0)
                {
                    return(Json(new { rs = "error", message = "该活动已关闭。" }));
                }
                if (subjectInfo.Status == 2)
                {
                    return(Json(new { rs = "error", message = "该活动未开启。" }));
                }
                if (subjectInfo.IsAudited != 1)
                {
                    return(Json(new { rs = "error", message = "该活动未审核完成。" }));
                }
                if (subjectInfo.DateEnd < DateTime.Now)
                {
                    return(Json(new { rs = "error", message = "该活动已经结束。" }));
                }
            }
            else
            {
                return(Json(new { rs = "error", message = "该活动不存在。" }));
            }
            #endregion


            //修改
            if (ID > 0)
            {
                SWfsSubjectFeaturedEvents model = service.GetFeatureEventInfo(ID);
                if (model.Location != location || model.DateShow != showDate)
                {
                    if (sfeList != null && sfeList.Count > 0)
                    {
                        return(Json(new { rs = "error", message = "同位置同时间不可创建大于两场含两场的主推。" }));
                    }
                }
                model.DateShow  = showDate;
                model.Location  = location;
                model.SubjectNo = subjectNo;
                #region   图片
                if (Request.Files["AdPicFile"] == null)
                {
                    if (!string.IsNullOrEmpty(model.SpreadPicture))
                    {
                        spreadPicture = Request.Params["hidAdPicUp"].ToString();//获取隐藏域中的值
                    }
                    else
                    {
                        return(Json(new { rs = "error", message = "请上传图片!" }));
                    }
                }
                else
                {
                    string picSize = AppSettingManager.AppSettings["ChannelFeAdPic"].ToString();
                    string picType = AppSettingManager.AppSettings["ChannelFeAdPicType"].ToString();
                    rsPic = commonService.PostImg(Request.Files["AdPicFile"], picSize, picType);
                    if (rsPic.Keys.Contains("error"))
                    {
                        return(Json(new { rs = "error", message = rsPic["error"] }));
                    }
                    if (rsPic.Keys.Contains("success"))
                    {
                        spreadPicture = rsPic["success"];
                    }
                }
                #endregion
                model.SpreadPicture = spreadPicture;
                try
                {
                    service.Update(model);
                    return(Json(new { rs = "ok", message = "修改成功。" }, "text/plain", Encoding.UTF8));
                }
                catch (Exception ex)
                {
                    return(Json(new { rs = "error", message = ex.Message }, "text/plain", Encoding.UTF8));
                }
            }
            else//添加
            {
                if (sfeList != null && sfeList.Count > 0)
                {
                    return(Json(new { rs = "error", message = "同位置同时间不可创建大于两场含两场的主推。" }));
                }
                #region   图片
                if (null != Request.Files["AdPicFile"] && Request.Files["AdPicFile"].ContentLength > 0)
                {
                    string picSize = AppSettingManager.AppSettings["ChannelFeAdPic"].ToString();
                    string picType = AppSettingManager.AppSettings["ChannelFeAdPicType"].ToString();
                    rsPic = new CommonService().PostImg(Request.Files["AdPicFile"], picSize, picType);
                    if (rsPic.Keys.Contains("error"))
                    {
                        return(Json(new { rs = "error", message = rsPic["error"] }));
                    }
                    if (rsPic.Keys.Contains("success"))
                    {
                        spreadPicture = rsPic["success"];
                    }
                }
                else
                {
                    return(Json(new { rs = "error", message = "请选择图片后上传!" }));
                }
                #endregion
                SWfsSubjectFeaturedEvents model = new SWfsSubjectFeaturedEvents()
                {
                    ChannelNo     = string.IsNullOrEmpty(channelNo) ? "" : channelNo,
                    SubjectNo     = subjectNo,
                    DateShow      = showDate,
                    Type          = 1,
                    Location      = location,
                    SpreadPicture = spreadPicture,
                    DateCreate    = DateTime.Now,
                    CreateUserId  = PresentationHelper.GetPassport().UserName
                };
                try
                {
                    service.Insert(model);
                    return(Json(new { rs = "ok", message = "添加成功。" }, "text/plain", Encoding.UTF8));
                }
                catch (Exception ex)
                {
                    return(Json(new { rs = "error", message = ex.Message }, "text/plain", Encoding.UTF8));
                }
            }
        }