public IActionResult ShowResultCurrencyConversion(CurrencyConversionModel model)
        {
            if (!ModelState.IsValid)
            {
                return(View("FormOfCurrencyConversion", model));
            }
            if (!_currencyNameChecker.CheckingIfCurrencyNamesAreDifferent(model.FirstCurrency, model.SecondCurrency))
            {
                ViewBag.ResultChekingCurrencyNameInConversion = "Currencies name must different";
                return(View("FormOfCurrencyConversion", model));
            }
            if (!_dateChecker.CheckingIfDateExistsForTwoCurrencies(model.Date, model.FirstCurrency, model.SecondCurrency))
            {
                ViewBag.DateRangeForConversion = _dateRange.GetDateRangeTwoCurrencies(model.FirstCurrency, model.SecondCurrency);

                return(View("FormOfCurrencyConversion", model));
            }
            return(View(_currencyConversionService.CalculateAmountForCurrencyConversion(model)));
        }
Exemplo n.º 2
0
        public IActionResult ShowResultCurrencyComparision(CurrenciesComparatorModel model)
        {
            if (!ModelState.IsValid)
            {
                return(View("FormOfCurrencyComparator", model));
            }
            if (!_currencyNameChecker.CheckingIfCurrencyNamesAreDifferent(model.FirstCurrencyCode, model.SecondCurrencyCode))
            {
                ViewBag.ResultChekingCurrencyNameInComparision = "Currencies name must different";
                return(View("FormOfCurrencyComparator", model));
            }
            if (!_dateChecker.CheckingIfDateExistsForTwoCurrencies(model.Date, model.FirstCurrencyCode, model.SecondCurrencyCode))
            {
                ViewBag.DateRangeForComparison = _dateRange.GetDateRangeTwoCurrencies(model.FirstCurrencyCode, model.SecondCurrencyCode);

                return(View("FormOfCurrencyComparator", model));
            }
            return(View(_currenciesComparator.CompareCurrencies(model)));
        }