public ActionResult Index([Range(1, int.MaxValue, ErrorMessage = "页码必须大于0")] int page = 1, [Range(1, 50, ErrorMessage = "页大小必须在0到50之间")] int size = 15) { var list = NoticeService.GetPages <DateTime, NoticeDto>(page, size, n => n.Status == Status.Display, n => n.ModifyDate, false); ViewData["page"] = new Pagination(page, size, list.TotalCount); return(CurrentUser.IsAdmin ? View("Index_Admin", list.Data) : View(list.Data)); }
public ActionResult Index(int page = 1, int size = 10) { var list = NoticeService.GetPages <DateTime, NoticeOutputDto>(page, size, out var total, n => n.Status == Status.Display, n => n.ModifyDate, false).ToList(); ViewBag.Total = total; ViewData["page"] = new Pagination(page, size); return(CurrentUser.IsAdmin ? View("Index_Admin", list) : View(list)); }
public ActionResult Index([Range(1, int.MaxValue, ErrorMessage = "页码必须大于0")] int page = 1, [Range(1, 50, ErrorMessage = "页大小必须在0到50之间")] int size = 15) { var list = NoticeService.GetPages <DateTime, NoticeDto>(page, size, n => n.Status == Status.Display, n => n.ModifyDate, false); ViewData["page"] = new Pagination(page, size, list.TotalCount); foreach (var n in list.Data) { n.ModifyDate = n.ModifyDate.ToTimeZone(HttpContext.Session.Get <string>(SessionKey.TimeZone)); n.PostDate = n.PostDate.ToTimeZone(HttpContext.Session.Get <string>(SessionKey.TimeZone)); } return(CurrentUser.IsAdmin ? View("Index_Admin", list.Data) : View(list.Data)); }
public ActionResult Index(int page = 1, int size = 10, int id = 0) { var list = NoticeService.GetPages <DateTime, NoticeOutputDto>(page, size, out var total, n => n.Status == Status.Display, n => n.ModifyDate, false).ToList(); ViewBag.Total = total; if (!CurrentUser.IsAdmin) { return(View(list)); } if (id == 0) { return(View("Index_Admin", list)); } var notice = NoticeService.GetById(id); ViewBag.Total = 1; return(View("Index_Admin", new List <NoticeOutputDto> { notice.MapTo <NoticeOutputDto>() })); }