Books.web/Controllers/HomeController.cs
(完整代码) 1KBusing System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using Books.Service.Entity;
using Books.Service;
using System.Linq.Expressions;
namespace Books.web.Controllers
{
public class HomeController : Controller
{
public BaseService<ClassifyEntity> classify { get; set; } = new BaseService<ClassifyEntity>();
public BookService book { get; set; } = new BookService();
// GET: Home
public ActionResult Index(int id,int index)
{
int total ;
Expression<Func<BookEntity, bool>> where;
if (id == 0)
where =e=>true;
else
where= e => e.ClassifyId == id;
ViewData["book"] = book.GetPageDate(8, index,out total, where);
ViewData["total"] = (total+7)/8;
ViewData["id"] = id;
return View();
}
public ActionResult Details(int id)
{
var bo= book.GetBook(id);
return View(bo);
}
public JsonResult Classify()
{
ViewBag.ip = Request.UserHostAddress;
var data = classify.GetAll().Select(e => new { id = e.Id, name = e.Name });
return Json(data);
}
}
}
24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明
AI 解读 AI
登录后可用,每次 10 算力,解读结果公开显示在下面。
还没有人解读过这个文件。