예제 #1
0
        public async Task <Guid> Insert(InsertAssetModel model)
        {
            var asset = _mapper.Map <Asset>(model);

            asset.Id = Guid.NewGuid();

            await _assetRepository.Insert(asset);

            return(asset.Id);
        }
예제 #2
0
        public async Task ImportFromYahooFinanceCsv(InsertAssetModel model, Stream fileStream)
        {
            var assetId = await _assetService.Insert(model);

            var marketPrices = CsvParserProvider.YahooFinanceCsvParser
                               .ReadFromStream(fileStream, Encoding.ASCII)
                               .Select(x => SetIdToMarketPrice(assetId, x.Result))
                               .ToList();

            await _marketPriceRepository.InsertMany(marketPrices);
        }
        public async Task ImportYahooFinanceCsv(string isin, AssetClass assetClass, string label, Currency currency, IFormFile file)
        {
            var model = new InsertAssetModel
            {
                Isin     = isin,
                Class    = assetClass,
                Label    = label,
                Currency = currency
            };

            using (var fileStream = file.OpenReadStream())
            {
                await _importMarketPriceService.ImportFromYahooFinanceCsv(model, fileStream);
            }
        }
 public async Task <Guid> Insert([FromBody] InsertAssetModel model)
 {
     return(await _assetService.Insert(model));
 }