/*---------------------------------------------------------------------------------------------------------*/
        /*---------------------------------Effective Spread API!!!-------------------------------------------------*/

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

            if (symbol != null)
            {
                effectivespreads = GetEffctiveSpreads(symbol);
            }

            EffectiveSpreadVM effectiveSpreadViewModel = getEffectiveSpreadVM(effectivespreads);

            return(View(effectiveSpreadViewModel));
        }
        public IActionResult SaveEffectiveSpreads(string symbol)
        {
            List <EffectiveSpread> effectivespreads = GetEffctiveSpreads(symbol);

            foreach (EffectiveSpread effectivespread in effectivespreads)
            {
                //Database will give PK constraint violation error when trying to insert record with existing PK.
                if (dbContext.EffectiveSpreads.Where(c => c.EffectiveSpreadId.Equals(effectivespread.EffectiveSpreadId)).Count() == 0)
                {
                    dbContext.EffectiveSpreads.Add(effectivespread);
                }
            }

            // persist the data
            dbContext.SaveChanges();

            // populate the models to render in the view
            ViewBag.dbSuccessChart = 1;
            EffectiveSpreadVM effectiveSpreadViewModel = getEffectiveSpreadVM(effectivespreads);

            return(View("EffectiveSpread", effectiveSpreadViewModel));
        }