public ActionResult Create(ModelArticle model, FormCollection fc) { ViewBag.Categorys = QueryCategoryAll(model.Categoryid.ToString()); ViewBag.CategorysTwo = QueryCategoryAll(model.CategoryTwo); var result = new ResultBase(); var resultMsg = string.Empty; var fileName = CommonMethod.ImageUpload(out result, this.HttpContext); if (result.result == -2) { ViewBag.CustomScript = UtilityScript.ShowMessage(result.resultMsg, isCreate: true); return View(model); } model.Context = fc["editorValue"]; model.Thumbnails = string.IsNullOrWhiteSpace(fileName) ? model.Thumbnails : fileName; model.Status = Convert.ToInt32(model.IsPermission); model.Isrecommend = Convert.ToInt32(model.IsRec); LogicArticle artDal = new LogicArticle(); var res = artDal.ArticleInsertUpdate(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); }
/// <summary> /// 新增文章 /// </summary> public ActionResult Create(string Id = null) { var model = new ModelArticle(); if (!string.IsNullOrWhiteSpace(Id)) { var idx = Convert.ToInt32(Id); LogicArticle artDal = new LogicArticle(); var resultMsg = string.Empty; model = artDal.ArticleDetail(out resultMsg, idx); model.IsPermission = model.Status == 1 ? true : false; model.IsRec = model.Isrecommend == 1 ? true : false; ViewBag.Categorys = QueryCategoryAll(model.Id.ToString()); ViewBag.CustomScript = string.Empty; } else { ViewBag.Categorys = QueryCategoryAll(); ViewBag.CustomScript = string.Empty; } return View(model); }
/// <summary> /// 新增文章 /// </summary> public ActionResult Create(string Id = null) { var model = new ModelArticle(); var customScript = string.Empty; IList<SelectListItem> categorys = new List<SelectListItem>(); IList<SelectListItem> categorysTwo = new List<SelectListItem>(); try { if (!string.IsNullOrWhiteSpace(Id)) { var idx = Convert.ToInt32(Id); LogicArticle artDal = new LogicArticle(); var resultMsg = string.Empty; model = artDal.ArticleDetail(out resultMsg, base.AuthorizeInfo, idx); model.IsPermission = model.Status == 1 ? true : false; model.IsRec = model.Isrecommend == 1 ? true : false; categorys = QueryCategoryAll(model.Id.ToString()); customScript = string.Empty; } else { model.Createdate = DateTime.Now; categorys = QueryCategoryAll(); customScript = string.Empty; } } catch (AuthorizeException ex) { customScript = Library.Common.UtilityScript.ShowMessage("系统出错,错误信息:" + ex.Message, title: "警告", isSuccess: false, funName: "GotoLogin"); } catch (Exception ex) { customScript = Library.Common.UtilityScript.ShowMessage("系统出错,错误信息:" + ex.Message, title: "警告"); } ViewBag.Categorys = categorys; ViewBag.CategorysTwo = categorysTwo; ViewBag.CustomScript = customScript; return View(model); }
private ModelArticle GetDataModel(string Id) { var idx = 0; var resultMsg = string.Empty; var logic = new LogicArticle(); int.TryParse(Id, out idx); var model = logic.ArticleDetail(out resultMsg, idx); if (!string.IsNullOrWhiteSpace(resultMsg) && resultMsg.Contains(BaseDict.ErrorPrefix)) { model.Context = resultMsg; } if (model.Id < 1) { model.Context = "未查询到数据!"; } return model; }
private ModelPagerArticle GetData(string Category = null, string CategoryTwo = null, string KeyWord = null, string PagerIndex = "1", string PagerSize = "30") { var model = new ModelPagerArticle(); model.PagerCount = 0; model.PagerIndex = 1; //if (!string.IsNullOrWhiteSpace(Category) || !string.IsNullOrWhiteSpace(CategoryTwo)) //{ var pageIndex = 0; var pageSize = 0; int.TryParse(PagerIndex, out pageIndex); int.TryParse(PagerSize, out pageSize); var rowCount = decimal.Zero; var resultMsg = string.Empty; LogicArticle artDal = new LogicArticle(); CriteriaArticle.Pager criteria = new CriteriaArticle.Pager(); criteria.CategoryId = string.IsNullOrWhiteSpace(Category) ? null : Category; criteria.CategoryTwo = string.IsNullOrWhiteSpace(CategoryTwo) ? null : CategoryTwo; criteria.KeyWord = string.IsNullOrWhiteSpace(KeyWord) ? null : KeyWord; var list = artDal.QueryArticleListPager(out resultMsg, out rowCount, criteria, pageSize: pageSize, pageIndex: pageIndex); model.ArtcleList = list; model.PagerCount = pageSize == 0 ? 0 : Math.Ceiling(rowCount / pageSize); model.PagerIndex = pageIndex; model.Category = Category; model.CategoryTwo = CategoryTwo; if (list.Count > 0) model.KeyWord = list.First().CategoryName; //} return model; }
public ActionResult Delete(string Id) { int idx = 0; int.TryParse(Id,out idx); var result = new ResultBase(); var resultMsg = string.Empty; LogicArticle artDal = new LogicArticle(); var res = artDal.ArticleDelete(out resultMsg, idx); if (res > 0) { result.result = 1; result.resultMsg = "删除成功!"; } else { result.result = -1; result.resultMsg = string.IsNullOrWhiteSpace(resultMsg) ? "删除失败!" : resultMsg; } return Json(result); }
public ActionResult Index(string Category, string CategoryTwo, string KeyWord, string PagerIndex, string PagerSize) { var pageIndex = 0; var pageSize = 0; int.TryParse(PagerIndex, out pageIndex); int.TryParse(PagerSize, out pageSize); var rowCount = decimal.Zero; var resultMsg = string.Empty; var model = new ModelPagerArticle(); ViewBag.Categorys = base.QueryCategoryAll(); ViewBag.CategorysTwo = base.QueryCategoryAll(); LogicArticle artDal = new LogicArticle(); CriteriaArticle.Pager criteria = new CriteriaArticle.Pager(); criteria.CategoryId = string.IsNullOrWhiteSpace(Category) ? null : Category; criteria.CategoryTwo = string.IsNullOrWhiteSpace(CategoryTwo) ? null : CategoryTwo; criteria.KeyWord = string.IsNullOrWhiteSpace(KeyWord) ? null : KeyWord; var list = artDal.QueryArticleListPager(out resultMsg, out rowCount, criteria, pageSize: pageSize, pageIndex: pageIndex); model.ArtcleList = list; model.PagerCount = pageSize == 0 ? 0 : Math.Ceiling(rowCount / pageSize); model.PagerIndex = pageIndex; return View(model); }
/// <summary> /// 获取小版块 文章类表 /// </summary> /// <param name="categoryCode"></param> /// <param name="adsCategoryCode"></param> /// <param name="categoryTwoCode"></param> /// <param name="topCount"></param> /// <returns></returns> private IList<ModelArticle> GetForumData(string categoryCode = null, string adsCategoryCode = null, string categoryTwoCode = null, string topCount = "5") { var logic = new LogicArticle(); var resultMsg = string.Empty; var CategIsAds = 0; var Introduction = string.Empty; var Thumbnails = string.Empty; var CategName = string.Empty; var categoryId = 0; var TopRowCount = 0; int.TryParse(topCount, out TopRowCount); int.TryParse(categoryCode,out categoryId); var list = logic.QueryArticleListTopByCategoryCode(out resultMsg, out CategIsAds, out Introduction, out Thumbnails, out CategName, base.AuthorizeInfo, categoryCode, categoryTwoCode, adsCategoryCode, TopRowCount); var model = logic.ArticleDetailByIsRecommend(out resultMsg,base.AuthorizeInfo, categoryId); ViewBag.CategIsAds = CategIsAds; ViewBag.Introduction = Introduction; ViewBag.Thumbnails = Thumbnails; ViewBag.CategName = CategName; ViewBag.CategoryCode = categoryCode; ViewBag.AdsCategoryCode = adsCategoryCode; ViewBag.ArtAbstract = model != null ? model.Abstract : string.Empty; ViewBag.ArtTitle = model != null ? model.Title : string.Empty; ViewBag.ArtId = model != null ? model.Id : 0; return list; }
/// <summary> /// 友情链接 /// </summary> public ActionResult LinksForum(string Id) { var resultMsg = string.Empty; var idx = 0; var logic = new LogicArticle(); int.TryParse(Id, out idx); var model = logic.ArticleDetail(out resultMsg,base.AuthorizeInfo, idx); return PartialView(model); }
public ActionResult Create(ModelArticle model, FormCollection fc) { var customScript = string.Empty; IList<SelectListItem> categorys = new List<SelectListItem>(); IList<SelectListItem> categorysTwo = new List<SelectListItem>(); try { categorys = QueryCategoryAll(model.Categoryid.ToString()); categorysTwo = QueryCategoryAll(model.CategoryTwo); var result = new ResultBase(); var resultMsg = string.Empty; var fileName = CommonMethod.ImageUpload(out result, this.HttpContext); if (result.result == -2) { customScript = UtilityScript.ShowMessage(result.resultMsg, isCreate: true); return View(model); } model.Context = fc["editorValue"]; model.Thumbnails = string.IsNullOrWhiteSpace(fileName) ? model.Thumbnails : fileName; model.Status = Convert.ToInt32(model.IsPermission); model.Isrecommend = Convert.ToInt32(model.IsRec); model.Createdate = model.Createdate; LogicArticle artDal = new LogicArticle(); var resultInsertUpdate = artDal.ArticleInsertUpdate(out resultMsg,base.AuthorizeInfo, model); if (resultInsertUpdate > 0) customScript = UtilityScript.ShowMessage(BaseDict.OperationSuccessfullyMsg, isCreate: true, isSuccess: true, funName: "Goto"); else customScript = UtilityScript.ShowMessage(resultMsg, isCreate: true, isSuccess: false, funName: "BtnShow"); } catch (AuthorizeException ex) { customScript = Library.Common.UtilityScript.ShowMessage("系统出错,错误信息:" + ex.Message, title: "警告", isSuccess: false, funName: "GotoLogin"); } catch (Exception ex) { customScript = Library.Common.UtilityScript.ShowMessage("系统出错,错误信息:" + ex.Message, title: "警告"); } ViewBag.Categorys = categorys; ViewBag.CategorysTwo = categorysTwo; ViewBag.CustomScript = customScript; return View(model); }
public ActionResult Index(string Category, string CategoryTwo, string KeyWord, string PagerIndex, string PagerSize) { var pageIndex = 0; var pageSize = 0; int.TryParse(PagerIndex, out pageIndex); int.TryParse(PagerSize, out pageSize); var customScript = string.Empty; IList<SelectListItem> categorys = new List<SelectListItem>(); IList<SelectListItem> categorysTwo = new List<SelectListItem>(); var rowCount = decimal.Zero; var resultMsg = string.Empty; var model = new ModelPagerArticle(); try { categorys = base.QueryCategoryAll(model.Category); categorysTwo = base.QueryCategoryAll(model.CategoryTwo); LogicArticle artDal = new LogicArticle(); CriteriaArticle.Pager criteria = new CriteriaArticle.Pager(); criteria.CategoryId = string.IsNullOrWhiteSpace(Category) ? null : Category; criteria.CategoryTwo = string.IsNullOrWhiteSpace(CategoryTwo) ? null : CategoryTwo; criteria.KeyWord = string.IsNullOrWhiteSpace(KeyWord) ? null : KeyWord; criteria.AuthorizeInfo = base.AuthorizeInfo; var list = artDal.QueryArticleListPager(out resultMsg, out rowCount, criteria, pageSize: pageSize, pageIndex: pageIndex); model.ArtcleList = list; model.PagerCount = pageSize == 0 ? 0 : Math.Ceiling(rowCount / pageSize); model.PagerIndex = pageIndex; } catch (AuthorizeException ex) { customScript = Library.Common.UtilityScript.ShowMessage("系统出错,错误信息:" + ex.Message, title: "警告", isSuccess: false, funName: "GotoLogin"); } catch (Exception ex) { customScript = Library.Common.UtilityScript.ShowMessage("系统出错,错误信息:" + ex.Message, title: "警告"); } ViewBag.CustomScript = customScript; ViewBag.Categorys = categorys; ViewBag.CategorysTwo = categorysTwo; return View(model); }
public ActionResult Delete(string Id) { int idx = 0; int.TryParse(Id, out idx); var result = new ResultBase(); var resultMsg = string.Empty; LogicArticle artDal = new LogicArticle(); try { var res = artDal.ArticleDelete(out resultMsg, base.AuthorizeInfo, idx); if (res > 0) { result.result = BaseNumber.OperationSuccessfullyNo; result.resultMsg = "删除成功!"; } else { result.result = BaseNumber.OperationFailedNo; result.resultMsg = string.IsNullOrWhiteSpace(resultMsg) ? "删除失败!" : resultMsg; } } catch (AuthorizeException ex) { result.result = BaseNumber.NotAuthorizeNo ; result.resultMsg = ex.Message; } catch (Exception ex) { result.result = BaseNumber.OperationFailedNo; result.resultMsg = ex.Message; } return Json(result); }