//testsang //Xem trong tuan dau, xem lai, trung binh public ActionResult GetAllCatAccessDetailType1ForChart(int catid, int year) //lay so lieu de hien thi tren bieu do so sanh các video cùng chương trình { var tabledata = _videoRepository.GetAllCatAccessDataType1(catid, year); //Không phải là chuyên đề if (tabledata.Videos == null) { return(Json(new { success = false }, JsonRequestBehavior.AllowGet)); } var firstWeekData = new List <AccessData>(); var reviewData = new List <AccessData>(); var firstWeek = new AccessDataChart() { name = "Tuần đầu", data = firstWeekData }; var review = new AccessDataChart() { name = "Coi lại", data = reviewData }; List <AccessDataChart> chartdata = new List <AccessDataChart> { review, firstWeek }; foreach (var videoItem in tabledata.Videos) { firstWeekData.Add(new AccessData { x = videoItem.Week, y = videoItem.FirstWeek.PageView, name = videoItem.Title }); reviewData.Add(new AccessData { x = videoItem.Week, y = videoItem.AllTime.PageView - videoItem.FirstWeek.PageView, name = videoItem.Title }); } return(Json(new { success = true, tabledata = tabledata, chartdata = chartdata }, JsonRequestBehavior.AllowGet)); }
public ActionResult GetAllCatAccessDetailType2ForChart(int catid, int year) //lay so lieu de hien thi tren bieu do so sanh cac chuyen muc { CatVideosReport tabledata = _videoRepository.GetAllCatAccessDataType2(catid, year); if (tabledata.Videos == null) { return(Json(new { success = false }, JsonRequestBehavior.AllowGet)); } var ipViewData = new List <AccessData>(); var reviewData = new List <AccessData>(); var ipView = new AccessDataChart() { name = "Xem không trùng", data = ipViewData }; var review = new AccessDataChart() { name = "Xem lại", data = reviewData }; List <AccessDataChart> chartdata = new List <AccessDataChart> { review, ipView }; foreach (var videoItem in tabledata.Videos) { ipViewData.Add(new AccessData { x = videoItem.Week, y = videoItem.IPViewCount, name = videoItem.Title }); reviewData.Add(new AccessData { x = videoItem.Week, y = videoItem.ReviewCount, name = videoItem.Title }); } return(Json(new { success = true, tabledata = tabledata, chartdata = chartdata, avg = 0 }, JsonRequestBehavior.AllowGet)); }