private StockTrend GetStockTrendInstance(CompanyQuote companyQuote) { StockTrend newstockTrend = new StockTrend(); newstockTrend.StockSymbol = companyQuote.Symbol; newstockTrend.StockName = companyQuote.name; newstockTrend.Price = companyQuote.Price; newstockTrend.Change = companyQuote.Change; newstockTrend.YearHigh = companyQuote.YearHigh; newstockTrend.YearLow = companyQuote.YearLow; return(newstockTrend); }
private void InsertStockTrendList(CompanyQuote companyQuote) { StockTrend newstockTrend = GetStockTrendInstance(companyQuote); lock (stocktrendLocker) { stockTrend.Add(newstockTrend); if (stockTrend.Count > 1)//save at least 2 entries at a time to minimize the db access. { InsertStockTrendToDB(stockTrend); stockTrend.Clear(); } } }
public IActionResult GetCompanyQuote() { inputSymbol = Convert.ToString(TempData["value"]); detailsOfCompany = GetCompanyQuote(inputSymbol); if (detailsOfCompany.Symbol == null) { ViewBag.IsModelEmpty = true; } else { ViewBag.IsModelEmpty = false; } _repository.SaveCompanyQuote(detailsOfCompany); return(View(detailsOfCompany)); }
private CompanyQuote GetCompanyQuote(string symbol) { CompanyQuote cQ = new CompanyQuote(); string CompanyQuote_End_Point = BASE_URL + "stock/" + symbol + "/quote"; string apiResponse = string.Empty; httpClient.BaseAddress = new Uri(CompanyQuote_End_Point); HttpResponseMessage response = httpClient.GetAsync(CompanyQuote_End_Point).GetAwaiter().GetResult(); if (response.IsSuccessStatusCode) { apiResponse = response.Content.ReadAsStringAsync().GetAwaiter().GetResult(); } if (!string.IsNullOrEmpty(apiResponse)) { cQ = JsonConvert.DeserializeObject <CompanyQuote>(apiResponse); } return(cQ); }
private void CheckToExludeDuplicateCompanyStocksInList(CompanyQuote item) { _dispatcherWrapper.BeginInvoke(DispatcherPriority.Normal, new Action(() => { lock (locker) { var ExistingQuote = CompanyQuotes.FirstOrDefault(x => x.Symbol == item.Symbol); if (ExistingQuote == null) { CompanyQuotes.Add(item); } else { CompanyQuotes.Remove(ExistingQuote); CompanyQuotes.Add(item); } } })); }
public CompanyQuote CreateDummyQuote(string sym) { if (sym == "testSymbol") { CompanyQuote companyQuote = new CompanyQuote(); companyQuote.Symbol = "testSymbol"; companyQuote.name = "TestCompanyName"; companyQuote.Price = "200"; return(companyQuote); } else { CompanyQuote companyQuote1 = new CompanyQuote(); companyQuote1.Symbol = "testSymbol2"; companyQuote1.name = "TestCompanyName2"; companyQuote1.Price = "202"; return(companyQuote1); } }