public IEnumerable<EmploymentCompany> FindByCriteria(EmploymentCompanyCriteria c) { return this.DbContext.EmploymentCompanies.Include("City").Include("User").Where(o => (!c.IdSrh.HasValue || o.Id.Equals(c.IdSrh.Value)) && (!c.IdFromSrh.HasValue || o.Id >= c.IdFromSrh.Value) && (!c.IdToSrh.HasValue || o.Id <= c.IdToSrh.Value) && (String.IsNullOrEmpty(c.NameSrh) || o.Name.Contains(c.NameSrh)) && (String.IsNullOrEmpty(c.TypeSrh) || o.Type.Contains(c.TypeSrh)) && (String.IsNullOrEmpty(c.ImportantSrh) || o.Important.Contains(c.ImportantSrh)) && (String.IsNullOrEmpty(c.WebsiteSrh) || o.Website.Contains(c.WebsiteSrh)) && (String.IsNullOrEmpty(c.TelephoneSrh) || o.Telephone.Contains(c.TelephoneSrh)) && (String.IsNullOrEmpty(c.FaxSrh) || o.Fax.Contains(c.FaxSrh)) && (String.IsNullOrEmpty(c.AddressSrh) || o.Address.Contains(c.AddressSrh)) && (!c.CityIdSrh.HasValue || (o.CityId.HasValue && o.CityId.Value.Equals(c.CityIdSrh.Value))) && (!c.CityIdFromSrh.HasValue || (o.CityId.HasValue && o.CityId.Value >= c.CityIdFromSrh.Value)) && (!c.CityIdToSrh.HasValue || (o.CityId.HasValue && o.CityId.Value <= c.CityIdToSrh.Value)) && (String.IsNullOrEmpty(c.IntroductionSrh) || o.Introduction.Contains(c.IntroductionSrh)) && (String.IsNullOrEmpty(c.SourceTypeSrh) || o.SourceType.Contains(c.SourceTypeSrh)) && (String.IsNullOrEmpty(c.RefererSrh) || o.Referer.Contains(c.RefererSrh)) && (!c.UserIdSrh.HasValue || (o.UserId.HasValue && o.UserId.Value.Equals(c.UserIdSrh.Value))) && (!c.UserIdFromSrh.HasValue || (o.UserId.HasValue && o.UserId.Value >= c.UserIdFromSrh.Value)) && (!c.UserIdToSrh.HasValue || (o.UserId.HasValue && o.UserId.Value <= c.UserIdToSrh.Value)) && (!c.EmployedQtySrh.HasValue || o.EmployedQty.Equals(c.EmployedQtySrh.Value)) && (!c.EmployedQtyFromSrh.HasValue || o.EmployedQty >= c.EmployedQtyFromSrh.Value) && (!c.EmployedQtyToSrh.HasValue || o.EmployedQty <= c.EmployedQtyToSrh.Value) && (String.IsNullOrEmpty(c.OldOaIdSrh) || o.OldOaId.Contains(c.OldOaIdSrh)) && (String.IsNullOrEmpty(c.TempProvIdSrh) || o.TempProvId.Contains(c.TempProvIdSrh)) && (String.IsNullOrEmpty(c.TempProvNameSrh) || o.TempProvName.Contains(c.TempProvNameSrh)) && (String.IsNullOrEmpty(c.TempCityIdSrh) || o.TempCityId.Contains(c.TempCityIdSrh)) && (String.IsNullOrEmpty(c.TempCityNameSrh) || o.TempCityName.Contains(c.TempCityNameSrh)) && (!c.AddTimeSrh.HasValue || (o.AddTime.HasValue && o.AddTime.Value.Equals(c.AddTimeSrh.Value))) && (!c.AddTimeFromSrh.HasValue || (o.AddTime.HasValue && o.AddTime.Value >= c.AddTimeFromSrh.Value)) && (!c.AddTimeToSrh.HasValue || (o.AddTime.HasValue && o.AddTime.Value <= c.AddTimeToSrh.Value)) ); }
public PagedModel<EmploymentCompany> Search(EmploymentCompanyCriteria c) { PagedModel<EmploymentCompany> m = new PagedModel<EmploymentCompany>(); var r = this.Repository.Search(c); if (!String.IsNullOrEmpty(c.sortname)) { if (c.sortname.ToLower().Equals("id")) { if (c.sortorder.ToLower().Equals("asc")) { r = r.OrderBy(o => o.Id); } else { r = r.OrderByDescending(o => o.Id); } } if (c.sortname.ToLower().Equals("name")) { if (c.sortorder.ToLower().Equals("asc")) { r = r.OrderBy(o => o.Name); } else { r = r.OrderByDescending(o => o.Name); } } if (c.sortname.ToLower().Equals("type")) { if (c.sortorder.ToLower().Equals("asc")) { r = r.OrderBy(o => o.Type); } else { r = r.OrderByDescending(o => o.Type); } } if (c.sortname.ToLower().Equals("important")) { if (c.sortorder.ToLower().Equals("asc")) { r = r.OrderBy(o => o.Important); } else { r = r.OrderByDescending(o => o.Important); } } if (c.sortname.ToLower().Equals("website")) { if (c.sortorder.ToLower().Equals("asc")) { r = r.OrderBy(o => o.Website); } else { r = r.OrderByDescending(o => o.Website); } } if (c.sortname.ToLower().Equals("telephone")) { if (c.sortorder.ToLower().Equals("asc")) { r = r.OrderBy(o => o.Telephone); } else { r = r.OrderByDescending(o => o.Telephone); } } if (c.sortname.ToLower().Equals("fax")) { if (c.sortorder.ToLower().Equals("asc")) { r = r.OrderBy(o => o.Fax); } else { r = r.OrderByDescending(o => o.Fax); } } if (c.sortname.ToLower().Equals("address")) { if (c.sortorder.ToLower().Equals("asc")) { r = r.OrderBy(o => o.Address); } else { r = r.OrderByDescending(o => o.Address); } } if (c.sortname.ToLower().Equals("cityid")) { if (c.sortorder.ToLower().Equals("asc")) { r = r.OrderBy(o => o.CityId); } else { r = r.OrderByDescending(o => o.CityId); } } if (c.sortname.ToLower().Equals("introduction")) { if (c.sortorder.ToLower().Equals("asc")) { r = r.OrderBy(o => o.Introduction); } else { r = r.OrderByDescending(o => o.Introduction); } } if (c.sortname.ToLower().Equals("sourcetype")) { if (c.sortorder.ToLower().Equals("asc")) { r = r.OrderBy(o => o.SourceType); } else { r = r.OrderByDescending(o => o.SourceType); } } if (c.sortname.ToLower().Equals("referer")) { if (c.sortorder.ToLower().Equals("asc")) { r = r.OrderBy(o => o.Referer); } else { r = r.OrderByDescending(o => o.Referer); } } if (c.sortname.ToLower().Equals("userid")) { if (c.sortorder.ToLower().Equals("asc")) { r = r.OrderBy(o => o.UserId); } else { r = r.OrderByDescending(o => o.UserId); } } if (c.sortname.ToLower().Equals("employedqty")) { if (c.sortorder.ToLower().Equals("asc")) { r = r.OrderBy(o => o.EmployedQty); } else { r = r.OrderByDescending(o => o.EmployedQty); } } if (c.sortname.ToLower().Equals("oldoaid")) { if (c.sortorder.ToLower().Equals("asc")) { r = r.OrderBy(o => o.OldOaId); } else { r = r.OrderByDescending(o => o.OldOaId); } } if (c.sortname.ToLower().Equals("tempprovid")) { if (c.sortorder.ToLower().Equals("asc")) { r = r.OrderBy(o => o.TempProvId); } else { r = r.OrderByDescending(o => o.TempProvId); } } if (c.sortname.ToLower().Equals("tempprovname")) { if (c.sortorder.ToLower().Equals("asc")) { r = r.OrderBy(o => o.TempProvName); } else { r = r.OrderByDescending(o => o.TempProvName); } } if (c.sortname.ToLower().Equals("tempcityid")) { if (c.sortorder.ToLower().Equals("asc")) { r = r.OrderBy(o => o.TempCityId); } else { r = r.OrderByDescending(o => o.TempCityId); } } if (c.sortname.ToLower().Equals("tempcityname")) { if (c.sortorder.ToLower().Equals("asc")) { r = r.OrderBy(o => o.TempCityName); } else { r = r.OrderByDescending(o => o.TempCityName); } } } m.RecordCount = r.Count(); if (c.pagesize.HasValue) { int page = c.page ?? 1; int pageCount = m.RecordCount / c.pagesize.Value; if (m.RecordCount % c.pagesize.Value > 0) { pageCount++; } int skip = (page - 1) * c.pagesize.Value; if (skip > 0) { r = r.Skip(skip); } r = r.Take(c.pagesize.Value); } m.Data = r.ToList(); return m; }
public ActionResult GetData(EmploymentCompanyCriteria c) { var m = new LigerGridModel(); this.BeforeGetData(c); var r = this.Service.FindByCriteria(c); this.AfterGetData(m, c, r); m.Total = r.RecordCount; r.Data.ForEach(o => { this.AddRowToGridModel(m, o); }); this.AfterBuildGridModel(m, c, r); return this.Json(m, JsonRequestBehavior.AllowGet); }
partial void BeforeGetData(EmploymentCompanyCriteria c);
partial void AfterGetData(LigerGridModel gm, EmploymentCompanyCriteria c, PagedModel<EmploymentCompany> pm);