public ActionResult HostSearchResult(int id = 0) { if (Session["Identity"] == null) { return RedirectToAction("login"); } int? count = context.getHostByNamePageCount(15, "%" + Request["query"] + "%"); ViewData["pageCount"] = id; ViewData["maxPage"] = count; IQueryable<getHostByNameByPageResult> ls = context.getHostByNameByPage(id + 1, 15, "%" + Request["query"] + "%"); List<HostListModal> showModel = new List<HostListModal>(); foreach (getHostByNameByPageResult s in ls) { HostListModal toAdd = new HostListModal() { employee_id = s.empolyee_id, age = DateTime.Now.Year - s.birthday.Year, address = s.empolyee_address, gender = s.gender, id_card = s.id_card, name = s.name, telephone = s.telephone, car_count = context.getTaxiCountByEmpolyeeId(s.empolyee_id) }; showModel.Add(toAdd); } ViewData.Model = showModel; return View(); }
public ActionResult HostList(int id = 0) { if (Session["Identity"] == null) { return RedirectToAction("login"); } int pageIndex = id; int pageSize = 15; int? count = context.getHostPageCount(pageSize); ViewData["pageCount"] = id; ViewData["maxPage"] = count; if (pageIndex >= count) pageIndex = (int)count - 1; IQueryable<getHostByPageResult> ls = context.getHostByPage(pageIndex + 1, pageSize); //IQueryable<getAllHostResult> ls = context.getAllHost(); int siz = ls.Count(); List<HostListModal> showModel = new List<HostListModal>(); foreach (getHostByPageResult s in ls) { HostListModal toAdd = new HostListModal() { employee_id = s.empolyee_id, age = DateTime.Now.Year - s.birthday.Year, address = s.empolyee_address, gender = s.gender, id_card = s.id_card, name = s.name, telephone = s.telephone, car_count = context.getTaxiCountByEmpolyeeId(s.empolyee_id) }; showModel.Add(toAdd); } ViewData.Model = showModel; return View(); }
public ActionResult HostList() { IQueryable<getAllHostResult> ls = context.getAllHost(); List<HostListModal> showModel = new List<HostListModal>(); foreach (getAllHostResult s in ls) { HostListModal toAdd = new HostListModal() { employee_id = s.empolyee_id, age = DateTime.Now.Year - s.birthday.Year, address = s.empolyee_address, gender = s.gender, id_card = s.id_card, name = s.name, telephone = s.telephone, car_count = context.getTaxiByOwnerEmpolyeeId(s.empolyee_id).Count() }; showModel.Add(toAdd); } ViewData.Model = showModel; return View(); }