public ActionResult Index()
        {
            var exchangeMatrix = new CurrencyExchangeMatrixViewModel();
            exchangeMatrix.Columns = new List<List<CurrencyExchangeViewModel>>();

            int x = 0;
            foreach (var currencyTo in _currencyRepository.Table)
            {
                int y = 0;
                var newColumn = new List<CurrencyExchangeViewModel>();
                foreach (var currencyFrom in _currencyRepository.Table)
                {
                    var exchange = new CurrencyExchangeViewModel();
                    // If it won't be a delivery from a country to the same country
                    // then populate the matrix with the real data.
                    if (x != y)
                    {
                        var record = _currencyExchangeRepository.Table
                            .Where(s => (s.CurrencyFrom.Id == currencyFrom.Id) && (s.CurrencyTo.Id == currencyTo.Id))
                            .FirstOrDefault();
                        if (record == null)
                        {
                            record = new CurrencyExchangeRecord();
                            record.CurrencyFrom = currencyFrom;
                            record.CurrencyTo = currencyTo;
                            _currencyExchangeRepository.Create(record);
                        }
                        exchange.Id = record.Id;
                        exchange.CurrencyFromId = record.CurrencyFrom.Id;
                        exchange.CurrencyFromCode = record.CurrencyFrom.Code;
                        exchange.CurrencyToId = record.CurrencyTo.Id;
                        exchange.CurrencyToCode = record.CurrencyTo.Code;
                        exchange.RateForBuyer = record.RateForBuyer;
                        exchange.RateForSeller = record.RateForSeller;
                        exchange.CurrencyFromFlagFileName = record.CurrencyFrom.FlagFileName;
                        exchange.CurrencyToFlagFileName = record.CurrencyTo.FlagFileName;

                    }
                    // It's an exchange from a currency to the same currency.
                    // just pass the empty setting to the view.
                    else
                    {
                        exchange.CurrencyFromCode = currencyFrom.Code;
                        exchange.CurrencyToCode = currencyTo.Code;
                        exchange.CurrencyFromFlagFileName = currencyFrom.FlagFileName;
                        exchange.CurrencyToFlagFileName = currencyTo.FlagFileName;
                    }
                    newColumn.Add(exchange);
                    y++;
                }
                exchangeMatrix.Columns.Add(newColumn);
                x++;
            }

            return View(exchangeMatrix);
        }
        public ActionResult Edit(CurrencyExchangeMatrixViewModel viewModel)
        {
            int x = 0;
            foreach (var column in viewModel.Columns)
            {
                int y = 0;
                foreach (var newExchange in column)
                {
                    // Dont save exchange rates from a currency to the same currency
                    if (x != y)
                    {
                        var record = _currencyExchangeRepository.Table
                                .Where(s => (s.CurrencyFrom.Id == newExchange.CurrencyFromId)
                                    && (s.CurrencyTo.Id == newExchange.CurrencyToId))
                                .First();

                        record.CurrencyFrom = _currencyRepository.Get(newExchange.CurrencyFromId);
                        record.CurrencyTo = _currencyRepository.Get(newExchange.CurrencyToId);
                        record.RateForBuyer = newExchange.RateForBuyer;
                        record.RateForSeller = newExchange.RateForSeller;
                        _currencyExchangeRepository.Update(record);
                    }
                    y++;
                }
                x++;
            }

            _orchardServices.Notifier.Information(T("Settings have been changed!"));
            return RedirectToAction("Index");
        }