Exemplo n.º 1
0
        public async Task <IActionResult> Edit(string id, [Bind("Symbol,CompanyName,MarketCap,Revenue,GrossProfit,Debt")] CompanyStats companyStats)
        {
            if (id != companyStats.Symbol)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(companyStats);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!CompanyStatsExists(companyStats.Symbol))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(companyStats));
        }
Exemplo n.º 2
0
        //[Route("{Name}/{id}")]
        public IActionResult CompanyStat(string Name, string id)
        {
            string symbol = id;

            ViewBag.dbSuccessComp = 0;
            CompanyStats companystat = GetCompanyStats(symbol);

            TempData["companystat"] = JsonConvert.SerializeObject(companystat);
            return(View(companystat));
        }
Exemplo n.º 3
0
        public async Task <IActionResult> Create([Bind("Symbol,CompanyName,MarketCap,Revenue,GrossProfit,Debt")] CompanyStats companyStats)
        {
            if (ModelState.IsValid)
            {
                _context.Add(companyStats);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(companyStats));
        }
Exemplo n.º 4
0
        /*
         *  Calls the IEX reference API to get the list of symbols.
         *  Returns a list of the companies whose information is available.
         */
        public CompanyStats GetCompanyStats(string symbol)
        {
            CompanyStats companyStats        = new CompanyStats();
            string       IEXTrading_API_PATH = BASE_URL + "/stock/" + symbol + "/stats";

            string statList = "";

            //List<Divident> dividends1 = new List<Divident>();
            httpClient.BaseAddress = new Uri(IEXTrading_API_PATH);

            HttpResponseMessage respose = httpClient.GetAsync(IEXTrading_API_PATH).GetAwaiter().GetResult();

            if (respose.IsSuccessStatusCode)
            {
                statList = respose.Content.ReadAsStringAsync().GetAwaiter().GetResult();
            }
            if (!statList.Equals(""))
            {
                companyStats = JsonConvert.DeserializeObject <CompanyStats>(statList);
                //companyStats.GetRange(0, companyStats.Le);
            }
            //dividends.AddRange(dividends1);
            return(companyStats);
        }