Exemplo n.º 1
0
        public ActionResult Add()
        {
            if (Session["UserId"] == null)
            {
                return Redirect("/admin/login");
            }

            NovelModel model = new NovelModel();

            NovelService novelService = new NovelService();
            model.NovelCategories = novelService.GetNovelCategories();

            return View(model);
        }
Exemplo n.º 2
0
        //
        // GET: /Admin/Novel/
        public ActionResult Index(string categoryId, string keywords, string page)
        {
            if (Session["UserId"] == null)
            {
                return Redirect("/admin/login");
            }

            NovelService novelService = new NovelService();

            int tempPage = 1;

            if (!string.IsNullOrEmpty(page))
            {
                Int32.TryParse(page, out tempPage);
            }

            NovelModel model = new NovelModel();

            //当前选中小说类别
            model.NovelCategories = novelService.GetNovelCategories();
            if (!string.IsNullOrEmpty(categoryId))
            {
                if (model.NovelCategories != null && model.NovelCategories.Count > 0)
                {
                    foreach (var item in model.NovelCategories)
                    {
                        if (item.Id == categoryId)
                        {
                            model.NovelCategory = item;
                            break;
                        }
                    }
                }
            }

            //小说列表
            int tempCount = 0;
            model.PageIndex = 1;
            model.Novels = novelService.GetNovelList(categoryId, keywords, 15, tempPage, out tempCount);
            //分页
            if (model.Novels != null && model.Novels.Count > 0)
            {
                model.PageIndex = tempPage;
                model.PageSize = 15;
                model.PageStep = 10;
                model.AllCount = tempCount;
                if (model.AllCount % model.PageSize == 0)
                {
                    model.PageCount = model.AllCount / model.PageSize;
                }
                else
                {
                    model.PageCount = model.AllCount / model.PageSize + 1;
                }
            }

            //关键字
            model.Keywords = keywords;

            if (model.NovelCategory == null)
            {
                model.NovelCategory = new NovelCategory();
            }

            return View(model);
        }
Exemplo n.º 3
0
        public ActionResult Article(int id)
        {
            if (Session["UserId"] == null)
            {
                return Redirect("/admin/login");
            }

            NovelModel model = new NovelModel();

            NovelService novelService = new NovelService();
            model.Novel = novelService.GetNovelById(id);
            model.NovelArticles = novelService.GetNovelArticles(id);

            return View(model);
        }