public static List <Office> GetOffices(bool activeOnly, int vendorId) { List <Office> offices; using (CustomClearviewEntities ctx = new CustomClearviewEntities()) { OfficeRepository repo = new OfficeRepository(ctx); offices = activeOnly ? repo.Filter(v => v.VendorId == vendorId && v.IsActive, sort => sort.OfficeName, SortOrder.Ascending, type => type.Vendor, type => type.Users) : repo.Filter(v => v.VendorId == vendorId, type => type.Vendor, type => type.Users); } return(offices); }