예제 #1
0
        /*---------------------------------------------------------------------------------------------------*/
        /*--------------------------------- Dividends API!!!-------------------------------------------------*/

        public IActionResult Dividend(string symbol)
        {
            //Set ViewBag variable first
            ViewBag.dbSuccessChart = 0;
            List <Dividend> diviends = new List <Dividend>();

            if (symbol != null)
            {
                diviends = GetDividends(symbol);
            }

            DividendVM diviendViewModel = getDividendVM(diviends);

            return(View(diviendViewModel));
        }
예제 #2
0
/*--------------------------------------------------------------Dividends API Endpoint---------------------------------------------------------------------------*/
/*------------------------------------------------------------- Dividend Action Method---------------------------------------------------------------------------*/

        //Dividends API
        public IActionResult Dividend(string symbol)

        {
            //Viewbag initiation
            ViewBag.dbSuccessChart = 0;
            List <Dividend> dividends = new List <Dividend>();

            if (symbol != null)
            {
                dividends = GetDividends(symbol);
            }

            DividendVM ReturnedDividends = getDividendVM(dividends);

            return(View(ReturnedDividends));
        }
예제 #3
0
        public IActionResult SaveDividends(string symbol)
        {
            List <Dividend> dividends = GetDividends(symbol);

            // save the quote if the quote has not already been saved in the database

            foreach (Dividend dividend in dividends)
            {
                //Database will give PK constraint violation error when trying to insert record with existing PK.
                if (dbContext.Dividends.Where(c => c.DividendId.Equals(dividend.DividendId)).Count() == 0)
                {
                    dbContext.Dividends.Add(dividend);
                }
            }

            // persist the data
            dbContext.SaveChanges();

            // populate the models to render in the view
            ViewBag.dbSuccessChart = 1;
            DividendVM diviendViewModel = getDividendVM(dividends);

            return(View("Dividend", diviendViewModel));
        }