Exemple #1
0
        public CurrencyModel Get(CurrencyRateSearchArgs args)
        {
            var response          = _bankService.GetCurrencies();
            var allCurrenciesList = response.Currency;
            IEnumerable <CurrencyModel> result = new List <CurrencyModel>();

            if (args != null)
            {
                if (args.Name != null && !string.IsNullOrEmpty(args.Name))
                {
                    result = allCurrenciesList.Where(x => x.Isim == args.Name);
                }
                if (args.CurrencyName != null && !string.IsNullOrEmpty(args.CurrencyName))
                {
                    result = allCurrenciesList.Where(x => x.CurrencyName == args.CurrencyName);
                }
                if (args.BanknoteSelling != null && !string.IsNullOrEmpty(args.BanknoteSelling))
                {
                    result = allCurrenciesList.Where(x => x.BanknoteSelling == args.BanknoteSelling);
                }
                if (args.BanknoteBuying != null && !string.IsNullOrEmpty(args.BanknoteBuying))
                {
                    result = allCurrenciesList.Where(x => x.BanknoteBuying == args.BanknoteBuying);
                }

                return(result.FirstOrDefault());
            }

            return(result.FirstOrDefault());
        }
Exemple #2
0
        public ResponseModel SortedBySelectedField(CurrencyRateSearchArgs args)
        {
            try
            {
                var response          = _bankService.GetCurrencies();
                var allCurrenciesList = response.Currency;

                if (args != null)
                {
                    if (args.Name != null && !string.IsNullOrEmpty(args.Name))
                    {
                        response.Currency = allCurrenciesList.OrderBy(x => x.Isim).ToList();
                    }
                    if (args.CurrencyName != null && !string.IsNullOrEmpty(args.CurrencyName))
                    {
                        response.Currency = allCurrenciesList.OrderBy(x => x.CurrencyName).ToList();
                    }
                    if (args.BanknoteSelling != null && !string.IsNullOrEmpty(args.BanknoteSelling))
                    {
                        response.Currency = allCurrenciesList.OrderBy(x => x.BanknoteSelling).ToList();
                    }
                    if (args.BanknoteBuying != null && !string.IsNullOrEmpty(args.BanknoteBuying))
                    {
                        response.Currency = allCurrenciesList.OrderBy(x => x.BanknoteBuying).ToList();
                    }

                    return(response);
                }

                return(response);
            }
            catch (Exception ex)
            {
                _logger.LogError(ex.Message);
                throw;
            }
        }