/// <summary> /// 编辑活动图 /// </summary> /// <returns></returns> public ActionResult NewActivityEdit() { SWfsChannelService service = new SWfsChannelService(); int picid = Convert.ToInt32(Request.QueryString["id"]); SWfsNewAlterPicInfo model = service.GetNewAlterPicInfoById(picid); if (null == model) { model = new SWfsNewAlterPicInfo(); } return(View(model)); }
public ActionResult NewActivityEditManage() { SWfsChannelService service = new SWfsChannelService(); int picid = Convert.ToInt32(Request["PictureId"]); //获取活动图信息 SWfsNewAlterPicInfo model = service.GetNewAlterPicInfoById(picid); #region 获取参数信息 string brandNo = Request.Form["BrandNo"].Trim(); //品牌编号 string picName = Request.Params["PicName"].Trim(); //图片名称 string pcPicture = ""; //主站图片 string pcUrl = Request.Params["NewPicFileUrlPC"].Trim(); //主站图片链接地址 string mobilePicture = ""; //移动端图片 string mobileUrl = Request.Params["NewPicFileUrlMobile"].Trim(); //移动端图片链接地址 int mobilePicType = Convert.ToInt32(Request.Params["PicType"]); //移动端图片类型 short status = Convert.ToInt16(Request.Params["Status"]); //活动图状态 DateTime startTime = Convert.ToDateTime(Request.Params["DateBegin"]); //开始时间 #endregion #region 验证图片 //网站图片 if (Request.Files["NewPicFilePC"] == null || string.IsNullOrEmpty(Request.Files["NewPicFilePC"].FileName)) { if (!string.IsNullOrEmpty(model.PcPictureNo)) { pcPicture = Request.Params["hidPcPic"].ToString();//获取隐藏域中的值 } else { return(Json(new { result = "error", message = "请上传图片!" })); } } else { CommonService commonService = new CommonService(); Dictionary <string, string> rsPic = commonService.PostImg(Request.Files["NewPicFilePC"], "width:770,Height:320,Length:500"); if (rsPic.Keys.Contains("error")) { return(Json(new { result = "error", message = rsPic["error"] })); } if (rsPic.Keys.Contains("success")) { pcPicture = rsPic["success"]; } } //移动端图片 if (Request.Files["NewPicFileMobile"] == null || string.IsNullOrEmpty(Request.Files["NewPicFileMobile"].FileName)) { if (!string.IsNullOrEmpty(model.MobilePictureNo)) { if (Request.Params["hidMobilePicType"] == mobilePicType.ToString()) { mobilePicture = Request.Params["hidMobilePic"].ToString();//获取隐藏域中的值 } else { if (mobilePicType == 1) { return(Json(new { result = "error", message = "请上传393*759图片!" })); } else if (mobilePicType == 2) { return(Json(new { result = "error", message = "请上传640*426图片!" })); } } } else { return(Json(new { result = "error", message = "请上传图片!" })); } } else { CommonService commonService = new CommonService(); string imgSize = "width:0,Height:0,Length:0"; if (mobilePicType == 1) { imgSize = "width:393,Height:759,Length:0";//长图 } else if (mobilePicType == 2) { imgSize = "width:640,Height:426,Length:0";//宽图 } Dictionary <string, string> rsMobilePic = commonService.PostImg(Request.Files["NewPicFileMobile"], imgSize); if (rsMobilePic.Keys.Contains("error")) { return(Json(new { result = "error", message = rsMobilePic["error"] })); } if (rsMobilePic.Keys.Contains("success")) { mobilePicture = rsMobilePic["success"]; } } #endregion #region 验证品牌 BrandInfo brandInfo = service.GetBrandInfoById(brandNo); if (brandInfo == null) { return(Json(new { result = "error", message = "对不起,该品牌不存在,请重新选择。" })); } #endregion /*List<SWfsNewAlterPicInfo> newAlterPicList = service.GetNewAlterPicInfoByNo(brandNo, startTime.ToString("yyyy-MM-dd")); * if (newAlterPicList != null && newAlterPicList.Count() > 0) * { * if (model.BrandNo == brandNo && model.BeginDate == startTime) * { * } * else * { * return Json(new { result = "error", message = "对不起,同一个品牌在同一天不能出现两次。" }); * } * }*/ model.PictureName = picName; model.Position = 0; model.BrandNo = brandNo; model.PcPictureNo = pcPicture; model.PcPictureLinkUrl = pcUrl; model.MobilePictureNo = mobilePicture; model.MobilePictureLinkUrl = mobileUrl; model.MobilePictureType = mobilePicType; model.Status = status; model.BeginDate = startTime; try { service.Update(model); return(Json(new { result = "success", message = "修改成功。" })); } catch (Exception ex) { return(Json(new { result = "error", message = ex.Message })); } }