public IActionResult AddArticle(Article model) { if (model.KId <= 0) { tip.Message = "请选择一个文章栏目"; return(Json(tip)); } if (string.IsNullOrWhiteSpace(model.Title)) { tip.Message = "请填写文章标题"; return(Json(tip)); } if (string.IsNullOrWhiteSpace(model.Content)) { tip.Message = "请填写文章内容"; return(Json(tip)); } if (!string.IsNullOrEmpty(model.Pic) && !Utils.IsImgFilename(model.Pic)) { tip.Message = "文章图片填写的不是图片格式!"; return(Json(tip)); } //处理文章更多图片 string[] moreImgSrc = Request.Form["nImgUrl"]; string morIMG = string.Empty;//更多图片的时候用到 if (moreImgSrc != null && moreImgSrc.Length > 0) { foreach (string s in moreImgSrc) { if (Utils.IsImgFilename(s)) { morIMG += s + "|||";//使用“|||”分隔图片 } } } string content = model.Content; if (Request.Form["autoSaveRemoteImg"] == "1" && !string.IsNullOrEmpty(content)) { content = ThumbnailHelper.SaveRemoteImgForContent(content); model.Content = content; } model.ItemImg = morIMG; model.AuthorId = Core.Admin.GetMyInfo().Id; model.Insert(); ArticleCategory.UpdateDetailCount(model.KId); SessionHelper.WriteSession("com_add_article_kid", model.KId); //添加TAG //Tag.InsertTags(model.Tags, RTType.RatuoModule.Article, model.Id, model.Title); Core.Admin.WriteLogActions("添加文章(id:" + model.Id + ");"); tip.Status = JsonTip.SUCCESS; tip.Message = "添加文章成功"; tip.ReturnUrl = "close"; return(Json(tip)); }
public IActionResult EditArticle(Article model) { if (model.Id <= 0) { tip.Message = "错误参数传递!"; Json(tip); } Article entity = Article.Find(Article._.Id == model.Id); if (entity == null) { tip.Message = "系统找不到本记录!"; return(Json(tip)); } if (string.IsNullOrWhiteSpace(model.Title)) { tip.Message = "文章标题不能为空!"; return(Json(tip)); } if (string.IsNullOrWhiteSpace(model.Content)) { tip.Message = "请填写文章内容"; return(Json(tip)); } if (!string.IsNullOrEmpty(model.Pic) && !Utils.IsImgFilename(model.Pic)) { tip.Message = "文章图片填写的不是图片格式!"; return(Json(tip)); } //处理 if (!string.IsNullOrEmpty(model.FileName) && !Utils.ChekHTMLFileNameIsOK(model.FileName)) { tip.Message = "静态化文件名错误,请填写正确的,或者留空!"; return(Json(tip)); } Admin my = Admin.GetMyInfo(); List <int> aclist = new List <int>(); if (my.Roles.IsSuperAdmin != 1) { aclist = JsonConvert.DeserializeObject <List <int> >(string.IsNullOrEmpty(my.Roles.AuthorizedArticleCagegory) ? "[]" : my.Roles.AuthorizedArticleCagegory); if (aclist == null) { aclist = new List <int>(); } if (aclist.Count > 0) { if (aclist.FindIndex(x => x == model.KId) == -1) { tip.Message = "当前选择栏目不存在,或者您没这个栏目的权限!"; return(Json(tip)); } } if (my.Roles.OnlyEditMyselfArticle == 1 && entity.AuthorId != my.Id) { tip.Message = "系统限制,您无法编辑非自己添加的文章!"; return(Json(tip)); } } //处理文章更多图片 string[] moreImgSrc = Request.Form["nImgUrl"]; string morIMG = string.Empty;//更多图片的时候用到 if (moreImgSrc != null && moreImgSrc.Length > 0) { foreach (string s in moreImgSrc) { if (Utils.IsImgFilename(s)) { morIMG += s + "|||";//使用“|||”分隔图片 } } } string isnew = Request.Form["IsNew"]; model.IsNew = isnew == "1" ? 1 : 0; string IsRecommend = Request.Form["IsRecommend"]; model.IsRecommend = IsRecommend == "1" ? 1 : 0; string IsHide = Request.Form["IsHide"]; model.IsHide = IsHide == "1" ? 1 : 0; //处理三个勾选属性的 model.Hits = entity.Hits; model.UpdateTime = DateTime.Now; model.ItemImg = morIMG; string content = model.Content; if (Request.Form["autoSaveRemoteImg"] == "1" && !string.IsNullOrEmpty(content)) { content = ThumbnailHelper.SaveRemoteImgForContent(content); model.Content = content; } entity.AddTime = model.AddTime; entity.AdsId = model.AdsId; entity.BannerImg = model.BannerImg; entity.Content = model.Content; entity.Description = model.Description; entity.FilePath = model.FilePath; entity.Hits = model.Hits; entity.Icon = model.Icon; entity.IsBest = model.IsBest; entity.IsComment = model.IsComment; entity.IsDel = model.IsDel; entity.IsHide = model.IsHide; entity.IsLock = model.IsLock; entity.IsMember = model.IsMember; entity.IsNew = model.IsNew; entity.IsRecommend = model.IsRecommend; entity.IsTop = model.IsTop; entity.ItemImg = morIMG; entity.Keyword = model.Keyword; entity.KId = model.KId; entity.LinkURL = model.LinkURL; entity.Location = model.Location; entity.Origin = model.Origin; entity.OriginURL = model.OriginURL; entity.Pic = model.Pic; entity.Sequence = model.Sequence; entity.SubTitle = model.SubTitle; entity.Tags = model.Tags; entity.TemplateFile = model.TemplateFile; entity.Title = model.Title; entity.TitleColor = model.TitleColor; entity.UpdateTime = DateTime.Now; entity.FileName = model.FileName; //model.AuthorId = Core.Admin.GetMyInfo().Id; entity.Update(); //Tag.ModifyTags(model.Tags, RTType.RatuoModule.Article, model.Id, model.Title); Core.Admin.WriteLogActions("编辑文章(id:" + model.Id + ");"); tip.Status = JsonTip.SUCCESS; tip.Message = "编辑文章详情成功"; tip.ReturnUrl = "close"; return(Json(tip)); }
public IActionResult AddArticle(Article model) { if (model.KId <= 0) { tip.Message = "请选择一个文章栏目"; return(Json(tip)); } if (string.IsNullOrWhiteSpace(model.Title)) { tip.Message = "请填写文章标题"; return(Json(tip)); } if (string.IsNullOrWhiteSpace(model.Content)) { tip.Message = "请填写文章内容"; return(Json(tip)); } if (!string.IsNullOrEmpty(model.Pic) && !Utils.IsImgFilename(model.Pic)) { tip.Message = "文章图片填写的不是图片格式!"; return(Json(tip)); } if (!string.IsNullOrEmpty(model.FileName) && !Utils.ChekHTMLFileNameIsOK(model.FileName)) { tip.Message = "静态化文件名错误,请填写正确的,或者留空!"; return(Json(tip)); } Admin my = Admin.GetMyInfo(); List <int> aclist = new List <int>(); if (my.Roles.IsSuperAdmin != 1) { aclist = JsonConvert.DeserializeObject <List <int> >(string.IsNullOrEmpty(my.Roles.AuthorizedArticleCagegory) ? "[]" : my.Roles.AuthorizedArticleCagegory); if (aclist == null) { aclist = new List <int>(); } if (aclist.Count > 0) { if (aclist.FindIndex(x => x == model.KId) == -1) { tip.Message = "当前选择栏目不存在,或者您没这个栏目的权限!"; return(Json(tip)); } } } //处理文章更多图片 string[] moreImgSrc = Request.Form["nImgUrl"]; string morIMG = string.Empty;//更多图片的时候用到 if (moreImgSrc != null && moreImgSrc.Length > 0) { foreach (string s in moreImgSrc) { if (Utils.IsImgFilename(s)) { morIMG += s + "|||";//使用“|||”分隔图片 } } } string content = model.Content; if (Request.Form["autoSaveRemoteImg"] == "1" && !string.IsNullOrEmpty(content)) { content = ThumbnailHelper.SaveRemoteImgForContent(content); model.Content = content; } model.ItemImg = morIMG; model.AuthorId = my.Id; model.Insert(); ArticleCategory.UpdateDetailCount(model.KId); SessionHelper.WriteSession("com_add_article_kid", model.KId); //添加TAG //Tag.InsertTags(model.Tags, RTType.RatuoModule.Article, model.Id, model.Title); Core.Admin.WriteLogActions("添加文章(id:" + model.Id + ");"); tip.Status = JsonTip.SUCCESS; tip.Message = "添加文章成功"; tip.ReturnUrl = "close"; return(Json(tip)); }
public IActionResult EditProduct(Product model) { if (model.Id <= 0) { tip.Message = "错误参数传递!"; Json(tip); } Product entity = Product.Find(Product._.Id == model.Id); if (entity == null) { tip.Message = "系统找不到本记录!"; return(Json(tip)); } if (model.KId <= 0) { tip.Message = "请选择一个商品分类"; return(Json(tip)); } if (string.IsNullOrWhiteSpace(model.Title)) { tip.Message = "请填写商品标题"; return(Json(tip)); } if (string.IsNullOrWhiteSpace(model.Content)) { tip.Message = "请填写商品介绍"; return(Json(tip)); } if (!string.IsNullOrEmpty(model.Pic) && !Utils.IsImgFilename(model.Pic)) { tip.Message = "商品图片填写的不是图片格式!"; return(Json(tip)); } Admin my = Admin.GetMyInfo(); List <int> aclist = new List <int>(); if (my.Roles.IsSuperAdmin != 1) { aclist = JsonConvert.DeserializeObject <List <int> >(string.IsNullOrEmpty(my.Roles.AuthorizedCagegory) ? "[]" : my.Roles.AuthorizedCagegory); if (aclist == null) { aclist = new List <int>(); } if (aclist.Count > 0) { if (aclist.FindIndex(x => x == model.KId) == -1) { tip.Message = "当前选择栏目不存在,或者您没这个栏目的权限!"; return(Json(tip)); } } if (my.Roles.OnlyEditMyselfProduct == 1 && entity.AuthorId != my.Id) { tip.Message = "系统限制,您无法编辑非自己添加的商品!"; return(Json(tip)); } } //处理商品更多图片 string[] moreImgSrc = Request.Form["nImgUrl"]; string morIMG = string.Empty;//更多图片的时候用到 if (moreImgSrc != null && moreImgSrc.Length > 0) { foreach (string s in moreImgSrc) { if (Utils.IsImgFilename(s)) { morIMG += s + "|||";//使用“|||”分隔图片 } } } //处理三个勾选属性的 string isnew = Request.Form["IsNew"]; model.IsNew = isnew == "1" ? 1 : 0; string IsRecommend = Request.Form["IsRecommend"]; model.IsRecommend = IsRecommend == "1" ? 1 : 0; string IsHide = Request.Form["IsHide"]; model.IsHide = IsHide == "1" ? 1 : 0; model.IsHotSales = Request.Form["IsHotSales"] == "1" ? 1 : 0; model.Hits = entity.Hits; model.UpdateTime = DateTime.Now; model.ItemImg = morIMG; string content = model.Content; if (Request.Form["autoSaveRemoteImg"] == "1" && !string.IsNullOrEmpty(content)) { content = ThumbnailHelper.SaveRemoteImgForContent(content); model.Content = content; } entity.SupportId = model.SupportId; entity.BannerImg = model.BannerImg; entity.BId = model.BId; entity.Color = model.Color; entity.Content = model.Content; entity.Credits = model.Credits; entity.Description = model.Description; entity.Discount = model.Discount; entity.Fare = model.Fare; entity.FilePath = model.FilePath; entity.Front = model.Front; entity.Hits = model.Hits; entity.Icon = model.Icon; entity.IsBest = model.IsBest; entity.IsBreakup = model.IsBreakup; entity.IsComment = model.IsComment; entity.IsGift = model.IsGift; entity.IsHide = model.IsHide; entity.IsHotSales = model.IsHotSales; entity.IsLock = model.IsLock; entity.IsMember = model.IsMember; entity.IsNew = model.IsNew; entity.IsPart = model.IsPart; entity.IsPromote = model.IsPromote; entity.IsRecommend = model.IsRecommend; entity.IsShelves = model.IsShelves; entity.IsSpecial = model.IsSpecial; entity.IsSubProduct = model.IsSubProduct; entity.IsTop = model.IsTop; entity.ItemImg = model.ItemImg; entity.ItemNO = model.ItemNO; entity.Keyword = model.Keyword; entity.KId = model.KId; entity.LinkURL = model.LinkURL; entity.MarketPrice = model.MarketPrice; entity.Material = model.Material; entity.Parameters = model.Parameters; entity.Pic = model.Pic; entity.PPId = model.PPId; entity.Price = model.Price; entity.Sequence = model.Sequence; entity.Service = model.Service; entity.ShopId = model.ShopId; entity.Spec = model.Spec; entity.SpecialPrice = model.SpecialPrice; entity.Stock = model.Stock; entity.SubTitle = model.SubTitle; entity.SupportId = model.SupportId; entity.Tags = model.Tags; entity.TemplateFile = model.TemplateFile; entity.Title = model.Title; entity.TitleColor = model.TitleColor; entity.Unit = model.Unit; entity.UpdateTime = DateTime.Now; entity.WarnStock = model.WarnStock; entity.Weight = model.Weight; entity.Update(); //添加TAG //Tag.InsertTags(model.Tags, RTType.RatuoModule.Product, model.Id, model.Title); Core.Admin.WriteLogActions("编辑商品(id:" + model.Id + ");"); tip.Status = JsonTip.SUCCESS; tip.Message = "编辑商品成功"; tip.ReturnUrl = "close"; return(Json(tip)); }
public IActionResult EditProduct(Product model) { if (model.Id <= 0) { tip.Message = "错误参数传递!"; Json(tip); } Product entity = Product.Find(Product._.Id == model.Id); if (entity == null) { tip.Message = "系统找不到本记录!"; return(Json(tip)); } if (model.KId <= 0) { tip.Message = "请选择一个商品分类"; return(Json(tip)); } if (string.IsNullOrWhiteSpace(model.Title)) { tip.Message = "请填写商品标题"; return(Json(tip)); } if (string.IsNullOrWhiteSpace(model.Content)) { tip.Message = "请填写商品介绍"; return(Json(tip)); } if (!string.IsNullOrEmpty(model.Pic) && !Utils.IsImgFilename(model.Pic)) { tip.Message = "商品图片填写的不是图片格式!"; return(Json(tip)); } Admin my = Admin.GetMyInfo(); List <int> aclist = new List <int>(); if (my.Roles.IsSuperAdmin != 1) { aclist = JsonConvert.DeserializeObject <List <int> >(string.IsNullOrEmpty(my.Roles.AuthorizedCagegory) ? "[]" : my.Roles.AuthorizedCagegory); if (aclist == null) { aclist = new List <int>(); } if (aclist.Count > 0) { if (aclist.FindIndex(x => x == model.KId) == -1) { tip.Message = "当前选择栏目不存在,或者您没这个栏目的权限!"; return(Json(tip)); } } if (my.Roles.OnlyEditMyselfProduct == 1 && entity.AuthorId != my.Id) { tip.Message = "系统限制,您无法编辑非自己添加的商品!"; return(Json(tip)); } } //处理商品更多图片 string[] moreImgSrc = Request.Form["nImgUrl"]; string morIMG = string.Empty;//更多图片的时候用到 if (moreImgSrc != null && moreImgSrc.Length > 0) { foreach (string s in moreImgSrc) { if (Utils.IsImgFilename(s)) { morIMG += s + "|||";//使用“|||”分隔图片 } } } //处理三个勾选属性的 string isnew = Request.Form["IsNew"]; model.IsNew = isnew == "1" ? 1 : 0; string IsRecommend = Request.Form["IsRecommend"]; model.IsRecommend = IsRecommend == "1" ? 1 : 0; string IsHide = Request.Form["IsHide"]; model.IsHide = IsHide == "1" ? 1 : 0; model.IsHotSales = Request.Form["IsHotSales"] == "1" ? 1 : 0; model.Hits = entity.Hits; model.UpdateTime = DateTime.Now; model.ItemImg = morIMG; string content = model.Content; if (Request.Form["autoSaveRemoteImg"] == "1" && !string.IsNullOrEmpty(content)) { content = ThumbnailHelper.SaveRemoteImgForContent(content); model.Content = content; } //model.AuthorId = Core.Admin.GetMyInfo().Id; model.Save(); //添加TAG //Tag.InsertTags(model.Tags, RTType.RatuoModule.Product, model.Id, model.Title); Core.Admin.WriteLogActions("编辑商品(id:" + model.Id + ");"); tip.Status = JsonTip.SUCCESS; tip.Message = "编辑商品成功"; tip.ReturnUrl = "close"; return(Json(tip)); }
public IActionResult EditArticle(Article model) { if (model.Id <= 0) { tip.Message = "错误参数传递!"; Json(tip); } Article entity = Article.Find(Article._.Id == model.Id); if (entity == null) { tip.Message = "系统找不到本记录!"; return(Json(tip)); } if (string.IsNullOrWhiteSpace(model.Title)) { tip.Message = "文章标题不能为空!"; return(Json(tip)); } if (string.IsNullOrWhiteSpace(model.Content)) { tip.Message = "请填写文章内容"; return(Json(tip)); } if (!string.IsNullOrEmpty(model.Pic) && !Utils.IsImgFilename(model.Pic)) { tip.Message = "文章图片填写的不是图片格式!"; return(Json(tip)); } //处理文章更多图片 string[] moreImgSrc = Request.Form["nImgUrl"]; string morIMG = string.Empty;//更多图片的时候用到 if (moreImgSrc != null && moreImgSrc.Length > 0) { foreach (string s in moreImgSrc) { if (Utils.IsImgFilename(s)) { morIMG += s + "|||";//使用“|||”分隔图片 } } } string isnew = Request.Form["IsNew"]; model.IsNew = isnew == "1" ? 1 : 0; string IsRecommend = Request.Form["IsRecommend"]; model.IsRecommend = IsRecommend == "1" ? 1 : 0; string IsHide = Request.Form["IsHide"]; model.IsHide = IsHide == "1" ? 1 : 0; //处理三个勾选属性的 model.Hits = entity.Hits; model.UpdateTime = DateTime.Now; model.ItemImg = morIMG; string content = model.Content; if (Request.Form["autoSaveRemoteImg"] == "1" && !string.IsNullOrEmpty(content)) { content = ThumbnailHelper.SaveRemoteImgForContent(content); model.Content = content; } entity.AddTime = model.AddTime; entity.AdsId = model.AdsId; entity.BannerImg = model.BannerImg; entity.Content = model.Content; entity.Description = model.Description; entity.FilePath = model.FilePath; entity.Hits = model.Hits; entity.Icon = model.Icon; entity.IsBest = model.IsBest; entity.IsComment = model.IsComment; entity.IsDel = model.IsDel; entity.IsHide = model.IsHide; entity.IsLock = model.IsLock; entity.IsMember = model.IsMember; entity.IsNew = model.IsNew; entity.IsRecommend = model.IsRecommend; entity.IsTop = model.IsTop; entity.ItemImg = morIMG; entity.Keyword = model.Keyword; entity.KId = model.KId; entity.LinkURL = model.LinkURL; entity.Location = model.Location; entity.Origin = model.Origin; entity.OriginURL = model.OriginURL; entity.Pic = model.Pic; entity.Sequence = model.Sequence; entity.SubTitle = model.SubTitle; entity.Tags = model.Tags; entity.TemplateFile = model.TemplateFile; entity.Title = model.Title; entity.TitleColor = model.TitleColor; entity.UpdateTime = DateTime.Now; //model.AuthorId = Core.Admin.GetMyInfo().Id; entity.Update(); //Tag.ModifyTags(model.Tags, RTType.RatuoModule.Article, model.Id, model.Title); Core.Admin.WriteLogActions("编辑文章(id:" + model.Id + ");"); tip.Status = JsonTip.SUCCESS; tip.Message = "编辑文章详情成功"; tip.ReturnUrl = "close"; return(Json(tip)); }
public IActionResult EditArticle(Article model) { if (model.Id <= 0) { tip.Message = "错误参数传递!"; Json(tip); } Article entity = Article.Find(Article._.Id == model.Id); if (entity == null) { tip.Message = "系统找不到本记录!"; return(Json(tip)); } if (string.IsNullOrWhiteSpace(model.Title)) { tip.Message = "文章标题不能为空!"; return(Json(tip)); } if (string.IsNullOrWhiteSpace(model.Content)) { tip.Message = "请填写文章内容"; return(Json(tip)); } if (!string.IsNullOrEmpty(model.Pic) && !Utils.IsImgFilename(model.Pic)) { tip.Message = "文章图片填写的不是图片格式!"; return(Json(tip)); } //处理文章更多图片 string[] moreImgSrc = Request.Form["nImgUrl"]; string morIMG = string.Empty;//更多图片的时候用到 if (moreImgSrc != null && moreImgSrc.Length > 0) { foreach (string s in moreImgSrc) { if (Utils.IsImgFilename(s)) { morIMG += s + "|||";//使用“|||”分隔图片 } } } //处理三个勾选属性的 string isnew = Request.Form["IsNew"]; model.IsNew = isnew == "1" ? 1 : 0; string IsRecommend = Request.Form["IsRecommend"]; model.IsRecommend = IsRecommend == "1" ? 1 : 0; string IsHide = Request.Form["IsHide"]; model.IsHide = IsHide == "1" ? 1 : 0; model.Hits = entity.Hits; model.UpdateTime = DateTime.Now; model.ItemImg = morIMG; string content = model.Content; if (Request.Form["autoSaveRemoteImg"] == "1" && !string.IsNullOrEmpty(content)) { content = ThumbnailHelper.SaveRemoteImgForContent(content); model.Content = content; } //model.AuthorId = Core.Admin.GetMyInfo().Id; model.Save(); //Tag.ModifyTags(model.Tags, RTType.RatuoModule.Article, model.Id, model.Title); Core.Admin.WriteLogActions("编辑文章(id:" + model.Id + ");"); tip.Status = JsonTip.SUCCESS; tip.Message = "编辑文章详情成功"; tip.ReturnUrl = "close"; return(Json(tip)); }