// GET: GoogleAnalyticsReport
        public ActionResult Index()
        {
            var analyticsModel    = GetModel();
            var response          = ReportingManager.GetAnalyticsResponse(analyticsModel, analyticsModel.CredStr);
            var analyticsResponse = new AnalyticsResponse
            {
                Model    = analyticsModel,
                Response = response
            };

            return(View(analyticsResponse));
        }
        // GET: GoogleAnalyticsReport
        public ActionResult Chart()
        {
            var analyticsModel = GetModel();
            var chart          = GetChartName();

            if (string.IsNullOrEmpty(chart))
            {
                return(View());
            }

            var response          = ReportingManager.GetAnalyticsResponse(analyticsModel, analyticsModel.CredStr);
            var analyticsResponse = new AnalyticsChartResponse
            {
                Model    = analyticsModel,
                Response = response,
                Chart    = chart
            };

            Dictionary <string, List <DataPoint> > dataDict = new Dictionary <string, List <DataPoint> >();

            foreach (var responseData in analyticsResponse.Response)
            {
                List <DataPoint> dataPoints1 = new List <DataPoint>();
                foreach (var metric in responseData.Metrics)
                {
                    DateRangeValues values = metric;
                    for (int k = 0; k < values.Values.Count; k++)
                    {
                        dataPoints1.Add(new DataPoint(chart, double.Parse(values.Values[k].ToString())));
                    }
                }
                dataDict.Add(responseData.Dimension[0], dataPoints1);
            }

            analyticsResponse.DataPoints = dataDict;
            List <ChartModel> model = new List <ChartModel>();

            foreach (var key in analyticsResponse.DataPoints.Keys)
            {
                model.Add(new ChartModel()
                {
                    dataPoints = analyticsResponse.DataPoints[key], showInLegend = true, name = key, type = chart, axisYType = "secondary"
                });
            }

            analyticsResponse.DataObject = JsonConvert.SerializeObject(model);

            return(View(analyticsResponse));
        }