private void SetStaffTypeList(int?type, bool allowBlank = true) { IStaffTypeService sts = new StaffTypeService(Settings.Default.db); StaffTypeSearchModel stsm = new StaffTypeSearchModel(); List <StaffType> st = sts.Search(stsm).ToList(); List <SelectListItem> select = new List <SelectListItem>(); if (allowBlank) { select.Add(new SelectListItem { Text = "", Value = "" }); } foreach (var it in st) { if (type.HasValue && type.ToString().Equals(it.id)) { select.Add(new SelectListItem { Text = it.name, Value = it.id.ToString(), Selected = true }); } else { select.Add(new SelectListItem { Text = it.name, Value = it.id.ToString(), Selected = false }); } } ViewData["staffTypeList"] = select; }
public IQueryable <StaffType> Search(StaffTypeSearchModel searchModel) { DataContext dc = new DataContext(this.DbString); IStaffTypeRepository staffTypeRep = new StaffTypeRepository(dc); return(staffTypeRep.Search(searchModel)); }
public IQueryable <StaffType> Search(StaffTypeSearchModel searchModel) { IQueryable <StaffType> stafftypes = this.context.StaffType; if (!string.IsNullOrEmpty(searchModel.Name)) { stafftypes = stafftypes.Where(c => c.name.Contains(searchModel.Name.Trim())); } return(stafftypes); }
public StaffTypeInfoModel GetStaffTypeInfo(StaffTypeSearchModel searchModel) { StaffTypeInfoModel info = new StaffTypeInfoModel(); DataContext dc = new DataContext(this.DbString); IStaffTypeRepository staffTypeRep = new StaffTypeRepository(dc); IQueryable <StaffType> staffTypes = staffTypeRep.Search(searchModel); info.staffTypeCount = dc.Context.GetTable <JobTitle>().Where(c => c.id.Equals(staffTypes.Count() > 0 ? staffTypes.First().id : -1)).Count(); return(info); }
public ActionResult Search([Bind(Include = "Name")] StaffTypeSearchModel q) { int pageIndex = 0; int.TryParse(Request.QueryString.Get("page"), out pageIndex); pageIndex = PagingHelper.GetPageIndex(pageIndex); IStaffTypeService ss = new StaffTypeService(Settings.Default.db); IPagedList <StaffType> staffTypes = ss.Search(q).ToPagedList(pageIndex, Settings.Default.pageSize); ViewBag.Query = q; return(View("Index", staffTypes)); }
public ActionResult Index(int?page) { int pageIndex = PagingHelper.GetPageIndex(page); StaffTypeSearchModel q = new StaffTypeSearchModel(); IStaffTypeService ss = new StaffTypeService(Settings.Default.db); IPagedList <StaffType> staffTypes = ss.Search(q).ToPagedList(pageIndex, Settings.Default.pageSize); ViewBag.Query = q; StaffTypeInfoModel info = ss.GetStaffTypeInfo(q); ViewBag.Info = info; return(View(staffTypes)); }