public ActionResult Edit(string id = null, string Category=null)
        {
            ModelCategory model = new ModelCategory();

            if (string.IsNullOrWhiteSpace(id))
            {
                model.Parentcateg = Category;
                ViewBag.Categorys = base.QueryCategoryAll(string.IsNullOrWhiteSpace(Category) ? null : Category);
                return View(model);
            }
            else
            {
                var idx = 0;
                int.TryParse(id, out idx);
                var resultMsg = string.Empty;
                LogicCategory logic = new LogicCategory();
                model = logic.CategoryDetail(out resultMsg, idx);
                if (model != null && string.IsNullOrWhiteSpace(model.Parentcateg)==false)
                {
                    ViewBag.Categorys = base.QueryCategoryAll(model.Parentcateg.ToString());
                }
                else
                {
                    ViewBag.Categorys = base.QueryCategoryAll();
                }

                if (resultMsg.Contains(BaseDict.ErrorPrefix))
                {
                    ViewBag.CustomScript = UtilityScript.ShowMessage(resultMsg, isCreate: true, isSuccess: true);
                }
                return View(model);
            }
        }
 public void CategoryDetailTest()
 {
     var resultMsg = string.Empty;
     LogicCategory logic = new LogicCategory();
     var model = logic.CategoryDetail(out resultMsg, 2);
     ModelCategory model1 = null;
     Assert.AreNotEqual(model, model1);
 }
Example #3
0
 /// <summary>
 /// 查询版块下所有分类
 /// </summary>
 /// <param name="selected">选中项</param> 
 protected IList<SelectListItem> QueryCategoryAll(string selected = null)
 {
     string resultMsg = string.Empty;
     LogicCategory dalCategory = new LogicCategory();
     var list = dalCategory.CategoryAllThree(out resultMsg, ParentCateg: 0);
     var slist = (from ModelCategory model in list
                  select new SelectListItem()
                  {
                      Selected = model.Id.ToString().Equals(selected) ? true : false,
                      Text = model.Name,
                      Value = model.Id.ToString()
                  }).ToList();
     return slist;
 }
        public ActionResult Delete(string Id)
        {
            int idx = 0;
            int.TryParse(Id, out idx);
            var result = new ResultBase();
            var resultMsg = string.Empty;
            LogicCategory logic = new LogicCategory();
            var res = logic.CategoryDelete(out resultMsg, idx);
            if (res > 0)
            {
                result.result = 1;
                result.resultMsg = "删除成功!";
            }
            else
            {
                result.result = -1;
                result.resultMsg = string.IsNullOrWhiteSpace(resultMsg) ? "删除失败!" : resultMsg;
            }

            return Json(result);
        }
        /// <summary>
        /// 杂志版块
        /// </summary> 
        public ActionResult MagazineIndex(string Category, string Year, string Month, string PagerIndex = "1", string PagerSize = "30")
        {
            Year = string.IsNullOrWhiteSpace(Year) ? DateTime.Now.Year.ToString() : Year;
            Month = string.IsNullOrWhiteSpace(Month) ? DateTime.Now.Month.ToString() : Month;
            var idx = 0;
            var iYear = 0;
            var iMonth = 0;
            int.TryParse(Year, out iYear);
            int.TryParse(Month, out iMonth);
            int.TryParse(Category, out idx);
            var resultMsg = string.Empty;
            var logic = new LogicCategory();
            var model = new ModelPagerArticle();
            var monthDays = DateTime.DaysInMonth(iYear, iMonth);
            var startDate = new DateTime(iYear, iMonth, 1, 0, 0, 0);
            var endDate = new DateTime(iYear, iMonth, monthDays, 23, 59, 59);
            var cateModel = logic.CategoryDetailByPid(out resultMsg, idx, startDate, endDate);

            if (cateModel != null)
            {
                ViewBag.CategoryName = cateModel.Name;
                ViewBag.Thumbnails = cateModel.Thumbnails;
                model = GetData(Category: cateModel.Id.ToString(), PagerIndex: PagerIndex, PagerSize: PagerSize);
                model.Year = Year;
                model.Month = Month;
                model.Category = Category;
            }

            return View(model);
        }
        /// <summary>
        /// 查询分类
        /// </summary> 
        private IList<ModelCategory> GetDataCategory(string Id)
        {
            var categoryId = 0;
            var resultMsg = string.Empty;
            var logic = new LogicCategory();

            int.TryParse(Id, out categoryId);

            IList<ModelCategory> list = new List<ModelCategory>();
            list = logic.CategoryAll(out resultMsg, categoryId, "2");
            var modelList = (from ModelCategory m in list
                             where m.Id == categoryId
                             select m).ToList();
            var model = modelList != null && modelList.Count > 0 ? modelList.First() : new ModelCategory();

            ViewBag.CategName = model.Name;
            ViewBag.CategoryCode = Id;
            list.Remove(model);

            return list;
        }
Example #7
0
 /// <summary>
 /// 查询分类实体
 /// </summary>
 /// <param name="Id"></param>
 /// <returns></returns>
 private ModelCategory GetCategoryDetail(string Id)
 {
     var resultMsg = string.Empty;
     var idx = 0;
     var logic = new LogicCategory();
     int.TryParse(Id, out idx);
     var model = logic.CategoryDetail(out resultMsg, idx);
     return model;
 }
Example #8
0
        /// <summary>
        /// 侧边栏 分类 子类列表
        /// </summary>
        /// <param name="categoryCode">父分类Id</param> 
        public ActionResult SidebarCategory(string categoryCode = null, string adsCategoryCode=null)
        {
            var categoryId = 0;
            var resultMsg = string.Empty;
            var logic = new LogicCategory();

            int.TryParse(categoryCode,out categoryId);

            IList<ModelCategory> list = new List<ModelCategory>();
            list = logic.CategoryAll(out resultMsg, categoryId, "2");
            var modelList = (from ModelCategory m in list
                         where m.Id == categoryId
                         select m).ToList();
            var model = modelList != null && modelList.Count > 0 ? modelList.First() : new ModelCategory();

            ViewBag.CategName = model.Name;
            ViewBag.Thumbnails = model.Thumbnails;
            ViewBag.CategoryCode = categoryCode;
            ViewBag.AdsCategoryCode = adsCategoryCode;

            list.Remove(model);

            return PartialView(list);
        }
Example #9
0
        /// <summary>
        /// 导航
        /// </summary> 
        public ActionResult Navigation()
        {
            var logic = new LogicCategory();
            var resultMsg = string.Empty;
            IList<ModelCategory> list = new List<ModelCategory>();
            list = logic.CategoryAll(out resultMsg, 1,"1");

            return PartialView(list);
        }
        public ActionResult Edit(ModelCategory model, FormCollection fc)
        {
            var resultMsg = string.Empty;
            ViewBag.Categorys = base.QueryCategoryAll(model.Parentcateg);
            var result = new ResultBase();

            //图片上传
            var fileName = CommonMethod.ImageUpload(out result, this.HttpContext);
            if (result.result == -2)
            {
                ViewBag.CustomScript = UtilityScript.ShowMessage(result.resultMsg, isCreate: true);
                return View(model);
            }
            model.Parentcateg = string.IsNullOrWhiteSpace(model.Parentcateg) ? "0" : model.Parentcateg;
            model.Thumbnails = string.IsNullOrWhiteSpace(fileName) ? model.Thumbnails : fileName;
            model.Introduction = fc["editorValue"];
            //数据保存
            LogicCategory logic = new LogicCategory();
            var res = logic.CategoryInsertUpdate(out resultMsg, model);
            if (res > 0)
            {
                resultMsg = "操作成功!";
                ViewBag.CustomScript = UtilityScript.ShowMessage(resultMsg, isCreate: true, isSuccess: true, funName: "Goto");
            }
            else
            {
                resultMsg = "操作失败,请检查数据是否正确后重新操作!";
                ViewBag.CustomScript = UtilityScript.ShowMessage(resultMsg, isCreate: true, isSuccess: true, funName: "BtnShow");
            }
            return View(model);
        }
        public ActionResult Tree(FormCollection fc)
        {
            string resultMsg = string.Empty;
            LogicCategory logic = new LogicCategory();
            var list = logic.CategoryAllThree(out resultMsg, ParentCateg: 0);

            var listTree = (from ModelCategory model in list
                            select new ModelTree() {
                                id = model.Id.ToString(),
                                name = model.Name,
                                pId = model.Parentcateg.ToString() }).ToList();

            return Json(listTree);
        }