public ActionResult Index(int pageIndex = 1) { var key = Request.QueryString["CategoryKey"]; var pageEntity = PageListHepler.BuildPageEntity(pageIndex, 8, "ContentId", "DESC"); var category = _categoryBll.Query(key, false); if (category == null) { throw new ArgumentNullException(nameof(category)); } var data = _contentBll.Page(pageEntity, category.CategoryId, category.ListJson); var timeFormat = new IsoDateTimeConverter { DateTimeFormat = "yyyy-MM-dd HH:mm:ss" }; ViewBag.Data = JsonConvert.SerializeObject(data, Formatting.Indented, timeFormat); ViewBag.ListHead = category.ListHead; ViewBag.ListTempalte = category.ListTempalte; ViewBag.CategoryId = category.CategoryId; var page = PageListHepler.BuildPagedList(data, pageEntity); return(View(page)); }
public ActionResult Save() { var saveState = BusinessHelper.BuildSaveState(Request); if (saveState == null) { throw new ArgumentNullException(nameof(saveState)); } switch (saveState.OperationState) { case OperationState.Add: case OperationState.Update: var categoryDto = _categoryBll.Query(saveState); var categoryTree = _categoryBll.GetList(); var modelList = _modelBll.GetList(); ViewBag.ModelList = modelList; ViewBag.CategoryTree = categoryTree; ViewBag.SaveState = saveState.ToJson(); return(View(categoryDto)); case OperationState.Remove: //逻辑删除 _categoryBll.HttpGetSave(saveState); return(RedirectToAction("Index", "Category")); default: throw new ArgumentOutOfRangeException(); } }