/// <summary> /// 新闻首页 /// </summary> public ActionResult Index(string category, string page) { this.Internationalization(); NewsModel model = new NewsModel(); if (string.IsNullOrEmpty(page)) { page = "1"; } NewsService newsService = new NewsService(); model.Page = Int32.Parse(page); model.PageSize = 10;//每页显示10张 model.PageIndex = Int32.Parse(page); int count = 0; //新闻列表 if (string.Equals(category, "news", StringComparison.CurrentCultureIgnoreCase)) { category = null; } model.NewsList = newsService.GetNewsList(category, null, model.PageSize, model.PageIndex, out count); //分页 if (model.NewsList != null && model.NewsList.Count > 0) { model.PageStep = 10; //页码10个 model.AllCount = count; if (model.AllCount % model.PageSize == 0) { model.PageCount = model.AllCount / model.PageSize; } else { model.PageCount = model.AllCount / model.PageSize + 1; } } if (category == null || string.Equals(category, "news", StringComparison.CurrentCultureIgnoreCase)) { CategoryService categoryService = new CategoryService(); model.Category = categoryService.GetCategoryById(category ?? "news"); } else { WitBird.Sex.Model.NewsCategory newsCategory = newsService.GetNewsCategoryById(category); model.Category = new Model.Category(); model.Category.Id = newsCategory.Id; model.Category.Name = newsCategory.Name; model.Category.Description = newsCategory.Description; model.Category.Keywords = newsCategory.Keywords; } //VideoService videoService = new VideoService(); //猜你喜欢 //model.Like = videoService.GetLike(16); return View(model); }
// // GET: /Admin/Category/ public ActionResult Index() { if (Session["UserId"] == null) { return Redirect("/admin/login"); } CategoryModel model = new CategoryModel(); CategoryService categoryService = new CategoryService(); model.Categories = categoryService.GetCategories(null); return View(model); }
public ActionResult Edit(string id) { if (Session["UserId"] == null) { return Redirect("/admin/login"); } CategoryModel model = new CategoryModel(); CategoryService categoryService = new CategoryService(); model.Category = categoryService.GetCategoryById(id); return View(model); }
/// <summary> /// 类别及分页 /// </summary> /// <param name="category">类别Id</param> /// <param name="page">类别分页页码</param> public ActionResult Category(string category, string page) { this.Internationalization(); CategoryModel model = new CategoryModel(); CategoryService categoryService = new CategoryService(); AlbumService albumService = new AlbumService(); model.Category = categoryService.GetCategoryById(category); model.PageSize = 30;//每页显示30张 int pageIndex = 1; if (Int32.TryParse(page, out pageIndex)) { model.PageIndex = pageIndex; } else { model.PageIndex = 1; } int count = 0; //分类列表 model.Albums = albumService.GetAlbumByCategoryId(category, model.PageSize, model.PageIndex, out count); //分页 if (model.Albums != null && model.Albums.Count > 0) { model.PageStep = 10; //页码10个 model.AllCount = count; if (model.AllCount % model.PageSize == 0) { model.PageCount = model.AllCount / model.PageSize; } else { model.PageCount = model.AllCount / model.PageSize + 1; } } if (model.Category == null) { model.Category = new Category(); } return View(model); }
/// <summary> /// 新闻首页 /// </summary> public ActionResult Index(string page) { this.Internationalization(); NewsModel model = new NewsModel(); if (string.IsNullOrEmpty(page)) { page = "1"; } NewsService newsService = new NewsService(); model.Page = Int32.Parse(page); model.PageSize = 10;//每页显示10张 model.PageIndex = Int32.Parse(page); int count = 0; //视频列表 model.NewsList = newsService.GetNewsList(null, null, model.PageSize, model.PageIndex, out count); //分页 if (model.NewsList != null && model.NewsList.Count > 0) { model.PageStep = 10; //页码10个 model.AllCount = count; if (model.AllCount % model.PageSize == 0) { model.PageCount = model.AllCount / model.PageSize; } else { model.PageCount = model.AllCount / model.PageSize + 1; } } CategoryService categoryService = new CategoryService(); model.Category = categoryService.GetCategoryById("news"); VideoService videoService = new VideoService(); //猜你喜欢 //model.Like = videoService.GetLike(16); return View(model); }
public ActionResult Edit(string id, string t, string k, string d) { if (Session["UserId"] == null) { return Redirect("/admin/login"); } CategoryService categoryService = new CategoryService(); if (!string.IsNullOrEmpty(id)) { Category category = categoryService.GetCategoryById(id); if (category != null) { category.Title = string.IsNullOrEmpty(t) ? string.Empty : t; category.Keywords = string.IsNullOrEmpty(k) ? string.Empty : k; category.Description = string.IsNullOrEmpty(d) ? string.Empty : d; categoryService.EditCategory(category); } } return Redirect("/admin/category/"); }
public static void UpdateCategories() { CategoryService service = new CategoryService(); categories = service.GetCategories(string.Empty); }