/// <summary> /// Takes sort parameters and returns IEnumerable<Model.Currency> object /// </summary> /// <param name="sorts">List of IndicativeExchangeRates.FilterSort.ExpressionSort object to sort data</param> /// <returns></returns> public static async Task <IEnumerable <Model.Currency> > GetSortedResult(List <ExpressionSort> sorts) { Log.Logger.Instance.Info($"UserName:{_username} - GetFilteredResult(List<ExpressionFilter> filters) executed"); if (Authentication.AuthService.IsAuthenticated == false) { Log.Logger.Instance.Error(new System.Security.Authentication.AuthenticationException($"UserName:{_username} - You must authenticate yourself!")); throw new System.Security.Authentication.AuthenticationException("You must authenticate yourself!"); } var response = await GetResult(); var expressionTree = CreateExpressionTree.GenerateOrderMethodCall <Model.Currency>(response, sorts); var result = (IOrderedQueryable <Model.Currency>)response.Provider.CreateQuery <Model.Currency>(expressionTree); return(result); }
/// <summary> /// Takes filters and returns IEnumerable<Model.Currency> object /// </summary> /// <param name="filters">List of IndicativeExchangeRates.FilterSort.ExpressionFilter object to filter data</param> /// <returns></returns> public static async Task <IEnumerable <Model.Currency> > GetFilteredResult(List <ExpressionFilter> filters) { Log.Logger.Instance.Info($"UserName:{_username} - GetFilteredResult(List<ExpressionFilter> filters) executed"); if (Authentication.AuthService.IsAuthenticated == false) { Log.Logger.Instance.Error(new System.Security.Authentication.AuthenticationException($"UserName:{_username} - You must authenticate yourself!")); throw new System.Security.Authentication.AuthenticationException("You must authenticate yourself!"); } var expressionTree = CreateExpressionTree.ConstructFilterExpressionTree <Model.Currency>(filters); var anonymousFunc = expressionTree.Compile(); var response = await GetResult(); var result = response.Where(anonymousFunc); return(result); }
/// <summary> /// Takes filters and sort parameters and returns IEnumerable<Model.Currency> object /// </summary> /// <param name="filters">List of IndicativeExchangeRates.FilterSort.ExpressionFilter object to filter data</param> /// <param name="sorts">List of IndicativeExchangeRates.FilterSort.ExpressionSort object to sort data</param> /// <returns></returns> public static async Task <IEnumerable <Model.Currency> > GetFilteredAndSortedResult(List <ExpressionFilter> filters, List <ExpressionSort> sorts) { Log.Logger.Instance.Info($"UserName:{_username} - GetFilteredAndSortedResult(List<ExpressionFilter> filters, List<ExpressionSort> sorts) executed"); if (Authentication.AuthService.IsAuthenticated == false) { Log.Logger.Instance.Error(new System.Security.Authentication.AuthenticationException($"UserName:{_username} - You must authenticate yourself!")); throw new System.Security.Authentication.AuthenticationException("You must authenticate yourself!"); } var expressionTreeFilter = CreateExpressionTree.ConstructFilterExpressionTree <Model.Currency>(filters); var anonymousFunc = expressionTreeFilter.Compile(); var response = await GetResult(); var filteredresult = response.Where(anonymousFunc).AsQueryable <Model.Currency>(); var expressionTreeSort = CreateExpressionTree.GenerateOrderMethodCall <Model.Currency>(filteredresult, sorts); var sortedresult = (IOrderedQueryable <Model.Currency>)filteredresult.Provider.CreateQuery <Model.Currency>(expressionTreeSort); return(sortedresult); }