using System.Linq; using JXCMS.CMS.Attribute; using JXCMS.CMS.Movie.Entity; using Microsoft.AspNetCore.Mvc; namespace JXCMS.CMS.Admin.Controllers { [Area("Admin")] [AdminAuthentication] public class CollectionController : Controller { public IActionResult Index(int pageNumber = 1, int pageSize = 20) { ViewBag.title = "采集地址"; var website = WebSiteEntity.Select.Count(out long count).Page(pageNumber, pageSize).ToList(); ViewBag.website = website; ViewBag.count = count; ViewBag.pageNumber = pageNumber; ViewBag.totlePage = count % pageSize == 0 ? count / pageSize : count / pageSize + 1; return View(); } [HttpPost] public IActionResult AddWebSite(WebSiteEntity webSiteEntity) { webSiteEntity.Save(); return Redirect(Url.Action("Index")); } public IActionResult DeleteWebSite(int id) { WebSiteEntity.Find(id).Delete(); return Redirect(Url.Action("Index")); } public IActionResult DeleteWebSiteBatch(int[] ids) { WebSiteEntity.Where(x => ids.Contains(x.Id)).ToDelete().ExecuteAffrows(); return Redirect(Url.Action("Index")); } public IActionResult EnableWebSiteBatch(int[] ids) { WebSiteEntity.Where(x => ids.Contains(x.Id)).ToUpdate() .Set(y => y.IsEnable, true).ExecuteAffrows(); return Redirect(Url.Action("Index")); } public IActionResult DisableWebSiteBatch(int[] ids) { WebSiteEntity.Where(x => ids.Contains(x.Id)).ToUpdate() .Set(y => y.IsEnable, false).ExecuteAffrows(); return Redirect(Url.Action("Index")); } public IActionResult WebSiteDialog(int id) { WebSiteEntity webSiteEntity = null; if (id == 0) { webSiteEntity = new WebSiteEntity(); ViewBag.title = "添加新网站"; } else { webSiteEntity = WebSiteEntity.Find(id); ViewBag.title = "修改" + webSiteEntity.WebSiteName; } return View(webSiteEntity); } } }