// GET: 查看待审核的受助请求列表 // 修改时间: 2019年5月3日 15点06分 public ActionResult CheckQuests(int currentPage = 1) { //新建视图模型列表 var res = new List <QuestsListViewModel>(); using (SSDBEntities db = new SSDBEntities()) { //所有待审核的受助请求 var qs = db.Quests.Where(x => x.Status == "正在审核中"); //1.分页 int totalThings = qs.Count(); //总共条目数目 ViewBag.totalPages = (int)Math.Ceiling(totalThings / (double)numPerPage); //总共页数 int start = (currentPage - 1) * numPerPage; //开始的条目 qs = qs.OrderByDescending(x => x.ReleaseTime).Skip(start).Take(numPerPage); ViewBag.currentPage = currentPage; //给视图模型赋值 foreach (var q in qs) { //新建一个视图模型并赋值 var tmp = new QuestsListViewModel(); tmp.Quest = q; //添加到列表中 res.Add(tmp); } } return(View(res)); }
public ActionResult Index(int?players, int?duration, int?price) { IEnumerable <QuestDTO> quests = questService.GetAll(); if (players != null) { quests = quests.Where(x => x.PlayersLimit <= players); } if (duration != null) { quests = quests.Where(x => x.Duration <= duration); } if (price != null) { quests = quests.Where(x => x.Price <= price); } QuestsListViewModel result = new QuestsListViewModel { Quests = quests.ToList(), Players = new SelectList(questService.GetAll().Select(x => x.PlayersLimit).Distinct().ToList()), Duration = new SelectList(questService.GetAll().Select(x => x.Duration).Distinct().ToList()), Price = new SelectList(questService.GetAll().Select(x => x.Price).Distinct().Where(x => x % 100 == 0).ToList()) }; return(View(result)); }
/// <summary> /// Returns a list of quests /// </summary> /// <param name="userID">The id of a user for user-related searches</param> /// <param name="completedQuests">Only include completed quests?</param> /// <param name="partiallyCompletedQuests">Only include partially completed quests?</param> /// <param name="incompleteQuests">Only include fully incomplete quests?</param> /// <param name="inactiveQuests">Include inactive quests?</param> /// <param name="trackedQuests">Show only tracked quests?</param> /// <param name="userGeneratedQuests">Include user generated quests?</param> /// <param name="search">A string for searching</param> /// <returns>A populated view model with a list of quests</returns> public JsonResult Quests( int?userID = null, bool completedQuests = false, bool partiallyCompletedQuests = false, bool incompleteQuests = false, bool inactiveQuests = false, bool trackedQuests = false, bool userGeneratedQuests = false, int?start = null, int?count = null, String search = null) { return(Json( QuestsListViewModel.Populate( userID, completedQuests, partiallyCompletedQuests, incompleteQuests, inactiveQuests, trackedQuests, userGeneratedQuests, start, count, search), JsonRequestBehavior.AllowGet)); }
/// <summary> /// The list of all quests /// </summary> /// <returns>GET: /Quests</returns> public ActionResult Index() { // Get the list of ALL achievements QuestsListViewModel model = QuestsListViewModel.Populate(); return(View(model)); }
// GET: 显示用户受助请求列表 // 修改时间: 2019年5月23日 14点19分 public ActionResult MyQuestsList(string keywords, string status, int currentPage = 1) { //获取当前用户id int usrId = (int)HttpContext.Session["usrId"]; //新建视图模型列表 var res = new List <QuestsListViewModel>(); using (SSDBEntities db = new SSDBEntities()) { //查找该用户发布的所有受助请求 var qs = db.Quests.Where(x => x.ReceiverId == usrId); //1.按照关键字搜索 if (keywords != null) { qs = qs.Where(x => x.Name.Contains(keywords)); } //2.按照状态筛选 switch (status) { case "All": break; case "1": qs = qs.Where(x => x.Status == "正在审核中"); break; case "2": qs = qs.Where(x => x.Status == "审核未通过"); break; case "3": qs = qs.Where(x => x.Status == "等待受助中"); break; case "4": qs = qs.Where(x => x.Status == "已接受受助"); break; case "5": qs = qs.Where(x => x.Status == "受助已成功"); break; } //3.分页 int totalThings = qs.Count(); //总共条目数目 ViewBag.totalPages = (int)Math.Ceiling(totalThings / (double)numPerPage); //总共页数 int start = (currentPage - 1) * numPerPage; //开始的条目 qs = qs.OrderByDescending(x => x.ReleaseTime).Skip(start).Take(numPerPage); ViewBag.searchString = keywords; ViewBag.Status = status; ViewBag.currentPage = currentPage; //给视图模型赋值 foreach (var q in qs) { //新建一个视图模型并赋值 var tmp = new QuestsListViewModel(); tmp.Quest = q; //添加到列表中 res.Add(tmp); } } return(View(res)); }