public static IList <T> Sort <T>(IList <T> records, string orderByString) { if (AllClientsOrderByType.IsValid(orderByString) || ClientOrderByType.IsValid(orderByString)) { return(records.AsQueryable().OrderBy(orderByString).ToList()); } throw new InvalidOperationException("Unknown AllClientsOrderByType Or ClientOrderByType QueryString"); }
public static bool IsValid(string orderByString) { ClientOrderByType orderByType = null; foreach (ClientOrderByType knownReportType in knownTypes) { if (orderByString == knownReportType.orderString) { orderByType = knownReportType; break; } } if (orderByType == null) { return(false); } return(true); }
public static ClientOrderByType Instantiate(string id) { ClientOrderByType orderByType = null; foreach (ClientOrderByType knownReportType in knownTypes) { if (id == knownReportType.orderString) { orderByType = knownReportType; break; } } if (orderByType == null) { throw new InvalidOperationException("Unknown orderBy Query String"); } return(orderByType); }