基本信息
源码名称:mvc 新闻管理系统源码下载(含数据库)
源码大小:11.84M
文件格式:.zip
开发语言:C#
更新时间:2014-10-09
友情提示:(无需注册或充值,赞助后即可获取资源下载链接)
嘿,亲!知识可是无价之宝呢,但咱这精心整理的资料也耗费了不少心血呀。小小地破费一下,绝对物超所值哦!如有下载和支付问题,请联系我们QQ(微信同号):813200300
本次赞助数额为: 2 元×
微信扫码支付:2 元
×
请留下您的邮箱,我们将在2小时内将文件发到您的邮箱
源码介绍
using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.Mvc; namespace NewsMangaerSystem.Controllers { public class NewsController : Controller { Mr.BLL.News nbll = new Mr.BLL.News(); Mr.BLL.NewsView nvbll = new Mr.BLL.NewsView(); // // GET: /News/ public ActionResult Index(string id) { ViewBag.SortId = id; return View(); } /// <summary> /// 所有文章 /// </summary> /// <param name="model"></param> /// <returns></returns> public JsonResult GetPageData(NewsMangaerSystem.Models.Model.SearchModel model) { string where = ""; if (model.NewsDateStart != DateTime.MinValue) { if (model.NewsDateEnd == DateTime.MinValue) { where = "NewsDate >" model.NewsDateStart; } else { where ="(NewsDate > " model.NewsDateStart " and NewsDate < " model.NewsDateEnd ")"; } } if (!string.IsNullOrEmpty(model.NewsKeyWord)) { where = "NewsTitle like '%" model.NewsKeyWord "%'"; } if (model.NewsSort > 0) { where = (where == "") ? "" : " and "; where = "NewsSortID=" model.NewsSort; } if (model.IsTJ) { where = (where == "") ? "" : " and "; where = "IsTJ =1"; } if (model.IsTop) { where = (where == "") ? "" : " and "; where = "IsTop =1"; } if (!string.IsNullOrEmpty(where)) { where = where " and NewsIsDelete=0"; } else { where = "NewsIsDelete=0"; } List<Mr.Model.NewsView> list = nvbll.GetModelList(where).OrderByDescending(m => m.NewsID).ToList(); List<Mr.Model.NewsView> listPage = list.Skip((model.pageNumber - 1) * model.pageSize).Take(model.pageSize).ToList(); var data = new { total = list.Count, rows = listPage }; return Json(data, JsonRequestBehavior.AllowGet); } public ActionResult Recently() { return View(); } /// <summary> /// 最近文章 /// </summary> /// <param name="model"></param> /// <returns></returns> public JsonResult GetPageDataRecently(NewsMangaerSystem.Models.Model.SearchModel model) { string where = ""; if (model.NewsDateStart != DateTime.MinValue) { if (model.NewsDateEnd == DateTime.MinValue) { where = "NewsDate >" model.NewsDateStart; } else { where = "(NewsDate > " model.NewsDateStart " and NewsDate < " model.NewsDateEnd ")"; } } if (!string.IsNullOrEmpty(model.NewsKeyWord)) { where = "NewsTitle like '%" model.NewsKeyWord "%'"; } if (model.NewsSort > 0) { where = (where == "") ? "" : " and "; where = "NewsSortID=" model.NewsSort; } if (model.IsTJ) { where = (where == "") ? "" : " and "; where = "IsTJ =1"; } if (model.IsTop) { where = (where == "") ? "" : " and "; where = "IsTop =1"; } if (!string.IsNullOrEmpty(where)) { where = where " and NewsIsDelete=0 and NewsID > " (nbll.GetMaxId()-1 - 50); } else { where = "NewsIsDelete=0 and NewsID > " (nbll.GetMaxId()-1 - 50) ; } List<Mr.Model.NewsView> list = nvbll.GetModelList(where).OrderByDescending(m => m.NewsID).ToList(); List<Mr.Model.NewsView> listPage = list.Skip((model.pageNumber - 1) * model.pageSize).Take(model.pageSize).ToList(); var data = new { total = list.Count, rows = listPage }; return Json(data, JsonRequestBehavior.AllowGet); } /// <summary> /// 置顶 /// </summary> /// <param name="id"></param> /// <returns></returns> public JsonResult ToTop(int id) { try { Mr.Model.News model = nbll.GetModel(id); model.IsTop = model.IsTop ? false : true; nbll.Update(model); return Json(true, JsonRequestBehavior.AllowGet); } catch { return Json(false, JsonRequestBehavior.AllowGet); } } /// <summary> /// 推荐 /// </summary> /// <param name="id"></param> /// <returns></returns> public JsonResult ToTJ(int id) { try { Mr.Model.News model = nbll.GetModel(id); model.IsTJ = model.IsTJ ? false : true; nbll.Update(model); return Json(true, JsonRequestBehavior.AllowGet); } catch { return Json(false, JsonRequestBehavior.AllowGet); } } // // GET: /News/Details/5 public ActionResult Details(int id) { return View(); } // // GET: /News/Create public ActionResult Create() { return View(); } // // POST: /News/Create [HttpPost] [ValidateInput(false)] public ActionResult Create(Mr.Model.News model) { try { HttpPostedFileBase fileImg = Request.Files["imgUpload"]; NewsMangaerSystem.Models.Common.Upload upload = new Models.Common.Upload(this.HttpContext); if (upload.Up(fileImg,"image")) { model.NewsSPicURL = upload.FileSUrl; model.NewsPicURL = upload.FileMUrl; model.NewsPicSourceUrl = upload.FileUrl; } else { model.NewsSPicURL = ""; model.NewsPicURL = ""; model.NewsPicSourceUrl = ""; } HttpPostedFileBase fileFile = Request.Files["fileUpload"]; if (upload.Up(fileFile,"file")) { model.NewsFileUrl = upload.FileUrl; model.NewsFileExe = upload.FileExe; } else { model.NewsFileUrl = ""; model.NewsFileExe = ""; } HttpPostedFileBase fileVideo = Request.Files["vdUpload"]; if (upload.Up(fileVideo,"video")) { model.NewsVidioUrl = upload.FileUrl; } else { model.NewsVidioUrl = ""; } nbll.Add(model); return RedirectToAction("Index"); } catch { return View(); } } // // GET: /News/Edit/5 public ActionResult Edit(int id) { return View(nbll.GetModel(id)); } // // POST: /News/Edit/5 [HttpPost] [ValidateInput(false)] public ActionResult Edit(Mr.Model.News model) { try { HttpPostedFileBase fileImg = Request.Files["imgUpload"]; HttpPostedFileBase fileFile = Request.Files["fileUpload"]; HttpPostedFileBase fileVideo = Request.Files["vdUpload"]; NewsMangaerSystem.Models.Common.Upload upload = new Models.Common.Upload(this.HttpContext); if (upload.Up(fileImg,"image")) { model.NewsSPicURL = upload.FileSUrl; model.NewsPicURL = upload.FileMUrl; model.NewsPicSourceUrl = upload.FileUrl; } if (upload.Up(fileFile,"file")) { model.NewsFileUrl = upload.FileUrl; model.NewsFileExe = upload.FileExe; } if (upload.Up(fileVideo,"video")) { model.NewsVidioUrl = upload.FileUrl; } nbll.Update(model); return RedirectToAction("Index"); } catch { return View(); } } // // GET: /News/Delete/5 /// <summary> /// 删除到回收站 /// </summary> /// <param name="id"></param> /// <returns></returns> public ActionResult Delete(int id) { nbll.DeleteToRecover(id); return RedirectToAction("Index"); } /// <summary> /// 彻底删除 /// </summary> /// <param name="id"></param> /// <returns></returns> public ActionResult Clear(int id) { nbll.Delete(id); return RedirectToAction("Index"); } /// <summary> /// 从回收站中恢复 /// </summary> /// <param name="id"></param> /// <returns></returns> public ActionResult Reback(int id) { nbll.RebackNewsByID(id); return RedirectToAction("Index"); } /// <summary> /// 文章回收站管理 /// </summary> /// <returns></returns> public ActionResult Recover() { return View(); } public JsonResult GetPageDataRecover(NewsMangaerSystem.Models.Model.SearchModel model) { string where = ""; if (model.NewsDateStart != DateTime.MinValue) { if (model.NewsDateEnd == DateTime.MinValue) { where = "NewsDate >" model.NewsDateStart; } else { where = "(NewsDate > " model.NewsDateStart " and NewsDate < " model.NewsDateEnd ")"; } } if (!string.IsNullOrEmpty(model.NewsKeyWord)) { where = "NewsTitle like '%" model.NewsKeyWord "%'"; } if (model.NewsSort > 0) { where = (where == "") ? "" : " and "; where = "NewsSortID=" model.NewsSort; } if (model.IsTJ) { where = (where == "") ? "" : " and "; where = "IsTJ =1"; } if (model.IsTop) { where = (where == "") ? "" : " and "; where = "IsTop =1"; } if (!string.IsNullOrEmpty(where)) { where = where " and NewsIsDelete=1"; } else { where = "NewsIsDelete=1"; } List<Mr.Model.NewsView> list = nvbll.GetModelList(where).OrderByDescending(m => m.NewsID).ToList(); List<Mr.Model.NewsView> listPage = list.Skip((model.pageNumber - 1) * model.pageSize).Take(model.pageSize).ToList(); var data = new { total = list.Count, rows = listPage }; return Json(data, JsonRequestBehavior.AllowGet); } } }