public JsonResult EditHandSlideAd(long id, string pic, string url) { HandSlideAdInfo handSlidAd = ServiceHelper.Create <ISlideAdsService>().GetHandSlidAd(id); if (!string.IsNullOrWhiteSpace(pic) && !handSlidAd.ImageUrl.Equals(pic)) { string str = Server.MapPath(pic); string str1 = "/Storage/Plat/ImageAd/"; string mapPath = IOHelper.GetMapPath(str1); if (!Directory.Exists(mapPath)) { Directory.CreateDirectory(mapPath); } IOHelper.CopyFile(str, Server.MapPath(str1), true, ""); pic = Path.Combine(str1, Path.GetFileName(str)); } ISlideAdsService slideAdsService = ServiceHelper.Create <ISlideAdsService>(); HandSlideAdInfo handSlideAdInfo = new HandSlideAdInfo() { Id = id, ImageUrl = pic, Url = url }; slideAdsService.UpdateHandSlidAd(handSlideAdInfo); return(Json(new { successful = true }, JsonRequestBehavior.AllowGet)); }
public JsonResult EditHandSlideAd(long id, string pic, string url) { var slide = _iSlideAdsService.GetHandSlidAd(id); if (!string.IsNullOrWhiteSpace(pic) && (!slide.ImageUrl.Equals(pic))) { if (pic.Contains("/temp/")) { string source = pic.Substring(pic.LastIndexOf("/temp")); string dest = @"/Storage/Plat/ImageAd/"; pic = Path.Combine(dest, Path.GetFileName(source)); Core.MallIO.CopyFile(source, pic, true); } else if (pic.Contains("/Storage/")) { pic = pic.Substring(pic.LastIndexOf("/Storage/")); } } _iSlideAdsService.UpdateHandSlidAd(new Entities.HandSlideAdInfo { Id = id, ImageUrl = pic, Url = url }); return(Json(new Result { success = true })); }