Example #1
0
        public override async Task ExecuteAsync(object parameter)
        {
            try
            {
                if (_importVM.dgCSVSecurities.Count != 0)
                {
                    Dictionary <string, int> assetClassMap = _importService.AssetClassMap();
                    Dictionary <string, int> currencyMap   = _importService.CurrencyMap();

                    List <SecuritiesDIM> newSecurities = new List <SecuritiesDIM>();
                    foreach (SecurityImportDataCSV data in _importVM.dgCSVSecurities)
                    {
                        SecuritiesDIM newSecurity = new SecuritiesDIM
                        {
                            AssetClassId       = assetClassMap[data.AssetClass],
                            CurrencyId         = currencyMap[data.Currency],
                            SecurityName       = data.Name,
                            FMPSymbol          = data.FMPSymbol,
                            ISIN               = data.ISIN,
                            Symbol             = data.Symbol,
                            AlphaVantageSymbol = data.AVSymbol
                        };
                        newSecurities.Add(newSecurity);
                    }

                    await _importService.AddImportedSecurities(newSecurities);
                }
            }
            catch (Exception e)
            {
                MessageBox.Show(e.Message);
            }
        }