/// <summary> /// 异步回调地址 /// </summary> /// <returns></returns> public ActionResult Ajax() { string action = CECRequest.GetQueryString("action"); if (action.Equals("childcid", StringComparison.OrdinalIgnoreCase)) { //获得子分类 IList <ShortCategoryInfo> list = new List <ShortCategoryInfo>(); int cid = CECRequest.GetQueryInt("cid", 0); var tempList = CategoryService.ListByParentId(cid); foreach (var item in tempList) { list.Add(new ShortCategoryInfo() { ParentId = item.ParentId, Id = item.Id, Name = item.Name.Replace('"', '”') }); } return(Json(list, JsonRequestBehavior.AllowGet)); } if (action.Equals("props", StringComparison.OrdinalIgnoreCase)) { //获得属性列表 int cid = CECRequest.GetQueryInt("cid", 0); List <ProductPropInfo> list = new List <ProductPropInfo>(); list = ProductPropService.List(cid); foreach (var item in list) { item.Name = item.Name.Replace('"', '”'); item.Value = item.Value.Replace('"', '”'); } return(Json(list, JsonRequestBehavior.AllowGet)); } return(Json(new { })); }
public ActionResult CatCreate(CategoryInfo modelInfo, FormCollection fc) { //判断是否选择中文 //如果选择中文,则是根目录,否则为子类别 bool isAdd = modelInfo.Id == 0 ? true : false; bool errors = false; int catId = Controleng.Common.Utils.StrToInt(fc["ddlCat"], 0); if (modelInfo.Id != GeneralConfig.ProductRootId_EN) { if (catId == 0) { errors = true; ModelState.AddModelError("CAT", "请选择分类"); } } if (string.IsNullOrEmpty(modelInfo.Name)) { errors = true; ModelState.AddModelError("NAME", "请输入名称"); } var parentModelInfo = CategoryService.Get(catId); if (CategoryService.ExistsName(modelInfo.Id, modelInfo.Name, parentModelInfo.Id)) { errors = true; ModelState.AddModelError("NAME", "分类名称不能重复"); } if (!errors && ModelState.IsValid) { //在这没判断别名是否重复,暂时没做 modelInfo.ParentId = catId; if (catId == 0) { modelInfo.ParentIdList = "0"; } else { modelInfo.ParentIdList = string.Format("{0},{1}", parentModelInfo.ParentIdList, modelInfo.ParentId); } CategoryService.Create(modelInfo); if (isAdd) { ViewBag.Msg = string.Format("添加成功!是否继续添加?<a href=\"catcreate?catId={0}\">【是】</a> <a href=\"catlist\">【否】</a>", CECRequest.GetQueryInt("catId", 0)); } else { ViewBag.Msg = "更新成功!<a href=\"catlist\">返回</a>"; } } return(View(modelInfo)); }
public ActionResult CatCreate(CategoryInfo modelInfo, FormCollection fc) { //判断是否选择中文 //如果选择中文,则是根目录,否则为子类别 bool isAdd = modelInfo.Id == 0 ? true : false; bool errors = false; int catId = Controleng.Common.Utils.StrToInt(fc["ddlCat"], 0); if (modelInfo.Id != GeneralConfig.ProductRootId_DE) { if (catId == 0) { errors = true; ModelState.AddModelError("CAT", "Please select the category"); } } if (string.IsNullOrEmpty(modelInfo.Name)) { errors = true; ModelState.AddModelError("NAME", "Please enter a name"); } var parentModelInfo = CategoryService.Get(catId); if (CategoryService.ExistsName(modelInfo.Id, modelInfo.Name, parentModelInfo.Id)) { errors = true; ModelState.AddModelError("NAME", "Category names can not be repeated"); } if (!errors && ModelState.IsValid) { //在这没判断别名是否重复,暂时没做 modelInfo.ParentId = catId; if (catId == 0) { modelInfo.ParentIdList = "0"; } else { modelInfo.ParentIdList = string.Format("{0},{1}", parentModelInfo.ParentIdList, modelInfo.ParentId); } CategoryService.Create(modelInfo); if (isAdd) { ViewBag.Msg = string.Format("Add success.Continue?<a href=\"catcreate?catId={0}\">【Yes】</a> <a href=\"catlist\">【No】</a>", CECRequest.GetQueryInt("catId", 0)); } else { ViewBag.Msg = ("Update success.<a href=\"List\">Back</a>"); } } return(View(modelInfo)); }
public ActionResult LoadChannelShowPage(SiteInfo currentSiteInfo, CategoryInfo catInfo) { //当前节点 var currentCategoryInfo = catInfo; //根节点 CategoryInfo rootCategoryInfo = currentCategoryInfo; //返回的模板HTML MvcHtmlString templateHtml = null; if (currentCategoryInfo != null && currentCategoryInfo.Id > 0) { //创建右边区域导航 if (currentCategoryInfo.IsShowFirstChildNode) { //如果显示一级子分类的第一个 var first = CategoryService.ListByParentId(currentCategoryInfo.Id, true).FirstOrDefault(); if (first != null && first.Id > 0) { currentCategoryInfo = first; } } #region == 动态加载模板开始 == //动态加载模板开始 switch (currentCategoryInfo.TemplateType) { case (int)TemplateType.ArticleListWithCategory: case (int)TemplateType.ArticleList: case (int)TemplateType.ArticleListWithTopOneImage: case (int)TemplateType.ArticleListWithImage: { string viewName = ((TemplateType)Enum.Parse(typeof(TemplateType), currentCategoryInfo.TemplateType.ToString())).ToString(); //文章列表(头一条带有图片) int pageIndex = CECRequest.GetQueryInt("page", 1); int pageSize = 10; var articleList = ArticleService.List(new SearchSetting() { PageIndex = pageIndex, PageSize = pageSize, SiteId = currentSiteInfo.Id, CategoryId = currentCategoryInfo.Id }, currentSiteInfo.Language); ViewDataDictionary vdd = new ViewDataDictionary(); vdd.Add("PageIndex", pageIndex); vdd.Add("PageSize", pageSize); vdd.Add("CurrentCategoryInfo", currentCategoryInfo); vdd.Add("Total", articleList.TotalItemCount); vdd.Add("ArticleList", articleList); vdd.Add("Language", currentSiteInfo.Language); templateHtml = Partial(viewName, articleList, vdd); } break; case (int)TemplateType.CategoryListWithOneColumn: { //根据当前ID获得一级子栏目 var categoryList = CategoryService.ListByParentId(currentCategoryInfo.Id, true); //对每一个分类,添加几条文章 //分类中有个ArticleList的扩展属性 var rows = 5; //显示5条 foreach (var item in categoryList) { item.ArticleList = ArticleService.ListWithoutPage(currentSiteInfo.Id, item.Id, rows, currentSiteInfo.Language); } ViewDataDictionary vdd = new ViewDataDictionary(); vdd.Add("Language", currentSiteInfo.Language); templateHtml = Partial(TemplateType.CategoryListWithOneColumn.ToString(), categoryList, vdd); } break; case (int)TemplateType.CategoryListWithTwoColumn: { //根据当前ID获得一级子栏目 var categoryList = CategoryService.ListByParentId(currentCategoryInfo.Id, true); templateHtml = Partial(TemplateType.CategoryListWithTwoColumn.ToString(), categoryList); } break; case (int)TemplateType.JobList: { int pageIndex = CECRequest.GetQueryInt("page", 1); int pageSize = 10; var jobList = JobService.List(new SearchSetting() { SiteId = currentSiteInfo.Id, PageIndex = pageIndex, PageSize = pageSize }); templateHtml = Partial(TemplateType.JobList.ToString(), jobList); } break; case (int)TemplateType.AttachmentList: { int pageIndex = CECRequest.GetQueryInt("page", 1); int pageSize = 10; var attachList = AttachmentService.List(new SearchSetting() { SiteId = currentSiteInfo.Id, PageIndex = pageIndex, PageSize = pageSize, CategoryId = currentCategoryInfo.Id }); templateHtml = Partial(TemplateType.AttachmentList.ToString(), attachList); } break; default: case (int)TemplateType.ShowSingleCategoryInfo: { //显示一条类别详细信息(图片和描述),不显示此类别下的文章 //如果此栏目默认显示自己子节点的第一条栏目,则取出子栏目的默认一条 //大部分是针对根节点来说的,有的时候根节点没有模板页,则点击根节点的时候,默认显示自己子节点的第一个栏目内容 templateHtml = Partial(TemplateType.ShowSingleCategoryInfo.ToString(), currentCategoryInfo); } break; } #endregion //设置当前类别的根结点信息 rootCategoryInfo = GetRootCategoryInfo(currentSiteInfo, currentCategoryInfo); ViewBag.RootCategoryInfo = rootCategoryInfo; ViewBag.CurrentCategoryInfo = currentCategoryInfo; //返回模板HTML ViewBag.TemplateHtml = templateHtml; //设置页面标题 ViewBag.Title = currentCategoryInfo.Name; } return(View("~/Views/Category/Show.cshtml")); }