public ShiftInfoModel GetShiftInfo(ShiftSearchModel searchModel) { ShiftInfoModel info = new ShiftInfoModel(); DataContext dc = new DataContext(this.DbString); IShiftRepository rep = new ShiftRepository(dc); IQueryable <Shift> results = rep.Search(searchModel); info.shiftCount = dc.Context.GetTable <Shift>().Where(c => c.id.Equals(results.Count() > 0 ? results.First().id : -1)).Count(); return(info); }
public ActionResult Index(int?page) { int pageIndex = PagingHelper.GetPageIndex(page); ShiftSearchModel q = new ShiftSearchModel(); IShiftService ss = new ShiftService(Settings.Default.db); IPagedList <Shift> models = ss.Search(q).ToPagedList(pageIndex, Settings.Default.pageSize); ViewBag.Query = q; ShiftInfoModel info = ss.GetShiftInfo(q); ViewBag.Info = info; return(View(models)); }