Ejemplo n.º 1
0
        public async Task <JsonResult> GetRate(CurrenciesViewModel model)
        {
            ModelState.Clear();
            string rate = await _rateHelper.GetRateAsync(model.SelectedBase, model.SelectedQuote, model.Date);

            return(Json(rate, JsonRequestBehavior.AllowGet));
        }
Ejemplo n.º 2
0
        public async Task <ActionResult> Index(CurrenciesViewModel model)
        {
            List <string> currenciesList = await _currenciesListHelper.GetCurrenciesListAsync();

            model.SelectedBase = currenciesList.FirstOrDefault
                                     (x => x.Contains(ConfigurationManager.AppSettings["DefaultBase"]));

            model.SelectedQuote = currenciesList.FirstOrDefault
                                      (x => x.Contains(ConfigurationManager.AppSettings["DefaultQuote"]));

            //Or defaults
            if (model.SelectedBase == null)
            {
                model.SelectedBase = currenciesList[0];
            }

            if (model.SelectedQuote == null)
            {
                model.SelectedQuote = currenciesList[1];
            }

            DatesRangeUIModel datesRangeModel = await _datesRangeHelper.GetDatesRangeAsync();

            model.StartDate           = DateTime.Parse(datesRangeModel.StartDate.ToString("dd-MM-yyyy"));
            model.EndDate             = DateTime.Parse(datesRangeModel.EndDate.ToString("dd-MM-yyyy"));
            model.Date                = model.EndDate;
            Session["CurrenciesList"] = currenciesList;

            model.Rate = await _rateHelper.GetRateAsync(model.SelectedBase, model.SelectedQuote, model.Date);

            return(View(model));
        }
Ejemplo n.º 3
0
        public MainViewModel(IAtomexApp app, IAccount account, string walletName, string appTheme = "light", bool restore = false)
        {
            var assembly = AppDomain.CurrentDomain
                           .GetAssemblies()
                           .First(a => a.GetName().Name == "atomex");

            var configuration = new ConfigurationBuilder()
                                .AddEmbeddedJsonFile(assembly, "configuration.json")
                                .Build();

            AtomexApp = app ?? throw new ArgumentNullException(nameof(AtomexApp));

            SubscribeToServices();

            var atomexClient = new WebSocketAtomexClient(
                configuration: configuration,
                account: account,
                symbolsProvider: AtomexApp.SymbolsProvider,
                quotesProvider: AtomexApp.QuotesProvider);

            AtomexApp.UseAtomexClient(atomexClient, restart: true);

            CurrenciesViewModel = new CurrenciesViewModel(AtomexApp, restore);
            SettingsViewModel   = new SettingsViewModel(AtomexApp, this, walletName);
            ConversionViewModel = new ConversionViewModel(AtomexApp);
            PortfolioViewModel  = new PortfolioViewModel(CurrenciesViewModel, appTheme);
            BuyViewModel        = new BuyViewModel(AtomexApp);

            _ = TokenDeviceService.SendTokenToServerAsync(App.DeviceToken, App.FileSystem, AtomexApp);
        }
Ejemplo n.º 4
0
        public async static void CurrencyView_Show()
        {
            var viewModel = new CurrenciesViewModel();
            await viewModel.InitAsync();

            var f = new Views.Directories.CurrencyView();

            f.DataContext = viewModel;
            f.ShowDialog();
        }
Ejemplo n.º 5
0
        // GET: Currencies / Index
        public ActionResult Index()
        {
            CurrencyContext context = new CurrencyContext();

            var viewModel = new CurrenciesViewModel
            {
                Currencies = context.Currency.ToList()
            };

            return(View(viewModel));
        }
        public CurrenciesListPage(CurrenciesViewModel currenciesViewModel)
        {
            InitializeComponent();
            BindingContext = currenciesViewModel;

            string selectedColorName = "ListViewSelectedBackgroundColor";

            if (Application.Current.RequestedTheme == OSAppTheme.Dark)
            {
                selectedColorName = "ListViewSelectedBackgroundColorDark";
            }

            Application.Current.Resources.TryGetValue(selectedColorName, out var selectedColor);
            selectedItemBackgroundColor = (Color)selectedColor;
        }
        public ActionResult Index(PagerParameters pagerParameters)
        {
            var viewModel = new CurrenciesViewModel();

            var pager = new Pager(_siteService.GetSiteSettings(), pagerParameters.Page, pagerParameters.PageSize);

            var currencies = _currencyRepository.Table
                             .FetchMany(c => c.CountryCurrencies)
                             .ThenFetch(c => c.CountryRecord)
                             .OrderBy(c => c.Name)
                             .Skip(pager.GetStartIndex())
                             .Take(pager.PageSize)
                             .ToList();

            var currencyItems = new List <CountryCurrencyItemViewModel>();

            foreach (var currency in currencies)
            {
                var currencyItem = new CountryCurrencyItemViewModel
                {
                    Id           = currency.Id,
                    Code         = currency.Code,
                    Name         = currency.Name,
                    ShortName    = currency.ShortName,
                    FlagFileName = currency.FlagFileName
                };

                var country = currency.CountryCurrencies.First().CountryRecord;
                currencyItem.CountryId = country != null ? country.Id : (int?)null;

                currencyItem.CountryName = country != null ? country.Name : null;

                currencyItems.Add(currencyItem);
            }

            viewModel.Currencies = currencyItems;

            var currenciesTotal = _currencyRepository.Table.Count();

            var pagerShape = Shape.Pager(pager).TotalItemCount(currenciesTotal);

            viewModel.Pager = pagerShape;

            return(View(viewModel));
        }
Ejemplo n.º 8
0
        internal CurrenciesView(CurrenciesViewModel viewModel)
        {
            InitializeComponent();

            DataContext = viewModel;
        }
Ejemplo n.º 9
0
        public ItemsPage()
        {
            this.InitializeComponent();

            this.BindingContext = this.viewModel = new CurrenciesViewModel();
        }
Ejemplo n.º 10
0
 public CurrenciesPage()
 {
     InitializeComponent();
     BindingContext = _viewModel = new CurrenciesViewModel();
 }
Ejemplo n.º 11
0
        public IActionResult Index(string type, string exchangerate, int page = 1, SortState sortOrder = SortState.CurrencyIDAsc)
        {
            int pageSize = 10;
            IQueryable <Currency> source = db.Currencies;

            if (!String.IsNullOrEmpty(type))
            {
                source = source.Where(p => p.NameCurrency.Contains(type));
            }
            if (exchangerate != null)
            {
                decimal tmp;
                if (Decimal.TryParse(exchangerate, out tmp))
                {
                    source = source.Where(p => p.Exchangerate == tmp);
                }
            }
            switch (sortOrder)
            {
            case SortState.CurrencyIDDesc:
                source = source.OrderByDescending(s => s.CurrencyID);
                break;

            case SortState.NameOfCurrencyAsc:
                source = source.OrderBy(s => s.NameCurrency);
                break;

            case SortState.NameOfCurrencyDesc:
                source = source.OrderByDescending(s => s.NameCurrency);
                break;

            case SortState.ExchangerateOfCurrencyAsc:
                source = source.OrderBy(s => s.Exchangerate);
                break;

            case SortState.ExchangerateOfCurrencyDesc:
                source = source.OrderByDescending(s => s.Exchangerate);
                break;

            case SortState.DateOfCurrencyAsc:
                source = source.OrderBy(s => s.date_);
                break;

            case SortState.DateOfCurrencyDesc:
                source = source.OrderByDescending(s => s.date_);
                break;

            default:
                source = source.OrderBy(s => s.CurrencyID);
                break;
            }
            var                       count                     = source.Count();
            var                       items                     = source.Skip((page - 1) * pageSize).Take(pageSize).ToList();
            PageViewModel             pageViewModel             = new PageViewModel(count, page, pageSize);
            CurrenciesFilterViewModel currenciesFilterViewModel = new CurrenciesFilterViewModel(type, exchangerate);
            CurrenciesViewModel       currencies                = new CurrenciesViewModel
            {
                Currencies      = items,
                PageViewModel   = pageViewModel,
                SortViewModel   = new CurrenciesSortViewModel(sortOrder),
                FilterViewModel = currenciesFilterViewModel
            };

            return(View(currencies));
        }