private IQueryable <Client> ApplySortOrder(ClientSearchViewModel viewModel, IQueryable <Client> query) { #region Apply sort order switch (viewModel.SortParameter) { case "NameSortParameter": query = query.OrderBy(q => q.Name); viewModel.NameSortParameter = MVCStringHelper.ConvertSortDirection(viewModel.SortParameter); break; case "NameSortParameter_desc": query = query.OrderByDescending(q => q.Name); viewModel.NameSortParameter = MVCStringHelper.ConvertSortDirection(viewModel.SortParameter); break; case "AccountsSortParameter": query = query.OrderBy(q => q.Accounts.Count()); viewModel.AccountsSortParameter = MVCStringHelper.ConvertSortDirection(viewModel.SortParameter); break; case "AccountsSortParameter_desc": query = query.OrderByDescending(q => q.Accounts.Count()); viewModel.AccountsSortParameter = MVCStringHelper.ConvertSortDirection(viewModel.SortParameter); break; case "AccountTotalSortParameter": query = query.OrderBy(q => q.Accounts.Sum(a => a.Balance)); viewModel.AccountTotalSortParameter = MVCStringHelper.ConvertSortDirection(viewModel.SortParameter); break; case "AccountTotalSortParameter_desc": query = query.OrderByDescending(q => q.Accounts.Sum(a => a.Balance)); viewModel.AccountTotalSortParameter = MVCStringHelper.ConvertSortDirection(viewModel.SortParameter); break; case "CreatedDateSortParameter": query = query.OrderBy(q => q.CreatedDate); viewModel.CreatedDateSortParameter = MVCStringHelper.ConvertSortDirection(viewModel.SortParameter); break; case "CreatedDateSortParameter_desc": query = query.OrderByDescending(q => q.CreatedDate); viewModel.CreatedDateSortParameter = MVCStringHelper.ConvertSortDirection(viewModel.SortParameter); break; case "ModifiedDateSortParameter": query = query.OrderBy(q => q.CreatedDate); viewModel.CreatedDateSortParameter = MVCStringHelper.ConvertSortDirection(viewModel.SortParameter); break; case "ModifiedDateSortParameter_desc": query = query.OrderByDescending(q => q.CreatedDate); viewModel.CreatedDateSortParameter = MVCStringHelper.ConvertSortDirection(viewModel.SortParameter); break; default: query = query.OrderBy(q => q.Name); break; } #endregion return(query); }
private IQueryable <Account> ApplySortOrder(AccountSearchViewModel viewModel, IQueryable <Account> query) { #region Apply sort order switch (viewModel.SortParameter) { case "AccountNumberSortParameter": query = query.OrderBy(q => q.AccountNumber); viewModel.AccountNumberSortParameter = MVCStringHelper.ConvertSortDirection(viewModel.SortParameter); break; case "AccountNumberSortParameter_desc": query = query.OrderByDescending(q => q.AccountNumber); viewModel.AccountNumberSortParameter = MVCStringHelper.ConvertSortDirection(viewModel.SortParameter); break; case "TitleSortParameter": query = query.OrderBy(q => q.Title); viewModel.TitleSortParameter = MVCStringHelper.ConvertSortDirection(viewModel.SortParameter); break; case "TitleSortParameter_desc": query = query.OrderByDescending(q => q.Title); viewModel.TitleSortParameter = MVCStringHelper.ConvertSortDirection(viewModel.SortParameter); break; case "ClientNameSortParameter": query = query.OrderBy(q => q.Client.Name); viewModel.ClientNameSortParameter = MVCStringHelper.ConvertSortDirection(viewModel.SortParameter); break; case "ClientNameSortParameter_desc": query = query.OrderByDescending(q => q.Client.Name); viewModel.ClientNameSortParameter = MVCStringHelper.ConvertSortDirection(viewModel.SortParameter); break; case "BalanceSortParameter": query = query.OrderBy(q => q.Balance); viewModel.BalanceSortParameter = MVCStringHelper.ConvertSortDirection(viewModel.SortParameter); break; case "BalanceSortParameter_desc": query = query.OrderByDescending(q => q.Balance); viewModel.BalanceSortParameter = MVCStringHelper.ConvertSortDirection(viewModel.SortParameter); break; case "CreatedDateSortParameter": query = query.OrderBy(q => q.CreatedDate); viewModel.CreatedDateSortParameter = MVCStringHelper.ConvertSortDirection(viewModel.SortParameter); break; case "CreatedDateSortParameter_desc": query = query.OrderByDescending(q => q.CreatedDate); viewModel.CreatedDateSortParameter = MVCStringHelper.ConvertSortDirection(viewModel.SortParameter); break; case "ModifiedDateSortParameter": query = query.OrderBy(q => q.ModifiedDate); viewModel.ModifiedDateSortParameter = MVCStringHelper.ConvertSortDirection(viewModel.SortParameter); break; case "ModifiedDateSortParameter_desc": query = query.OrderByDescending(q => q.ModifiedDate); viewModel.ModifiedDateSortParameter = MVCStringHelper.ConvertSortDirection(viewModel.SortParameter); break; default: query = query.OrderBy(q => q.AccountNumber); break; } #endregion return(query); }