Ejemplo n.º 1
0
        public virtual async Task <ActionResult> Delete(string symbol)
        {
            symbol = symbol.ToUpper();
            try
            {
                var result = await _appRepository.DeleteManyAsync <T>(r => r.Symbol.Equals(symbol));

                return(Ok(result >= 0));
            }
            catch (Exception ex)
            {
                _logger.LogError($"Error occurred while performing Delete operation; error:\n {ex.Message} ");
                return(StatusCode(StatusCodes.Status500InternalServerError, "Something went wrong while performing Delete operation"));
            }
        }
Ejemplo n.º 2
0
        public async Task <bool> StoreValuesToDb()
        {
            if (slickChartFirmNames == null || slickChartFirmNames.Count == 0)
            {
                return(false);
            }
            var scfnDB = mapper.Map <List <SlickChartFirmNamesDB> >(slickChartFirmNames);

            for (int i = 0; i < scfnDB.Count; i++)
            {
                IAPPDoc aPPDoc = scfnDB[i];
                scfnDB[i] = (SlickChartFirmNamesDB)DBValuesSetup.SetAppDocValues(aPPDoc);
            }
            var deleteCount = await appRepository.DeleteManyAsync <SlickChartFirmNamesDB>(r => r.ComputeDate <= scfnDB[0].ComputeDate);

            await appRepository.AddManyAsync(scfnDB);

            await DBValuesSetup.CreateIndex <SlickChartFirmNamesDB>(appRepository);

            return(true);
        }
        public async Task <bool> GetPricingData()
        {
            try
            {
                if (securityList == null || securityList.Count == 0)
                {
                    return(false);
                }
                var    queryTickers = string.Join(',', securityList);
                string urlStr       = quotesAPI.Replace(@"{tickersToUse}", queryTickers)
                                      .Replace(@"{apiKey}", apiKey);
                string tdaResponse = await client.GetStringAsync(urlStr);

                if (tdaResponse.IsNullOrWhiteSpace())
                {
                    return(false);
                }
                //logger.LogDebug(tdaResponse);
                List <DailyPriceDB> currentPricesDB = ConvertPriceJsonToObjects(tdaResponse);
                var listOfSymbols = from a in currentPricesDB
                                    select a.Symbol;

                var recordsDeleted = await appRepository.DeleteManyAsync <DailyPriceDB>(r => listOfSymbols.Contains(r.Symbol));

                await appRepository.AddManyAsync(currentPricesDB);

                await DBValuesSetup.CreateIndex <DailyPriceDB>(appRepository);

                return(true);
            }
            catch (Exception ex)
            {
                logger.LogError("Issues getting data from TDA");
                logger.LogError($"Error details \n\t{ex.Message}");
                return(false);
            }
        }