diff --git a/SchoolAgainStudy/SchoolAgainStudyBusinessLogic/BusinessLogic/ChartLogic.cs b/SchoolAgainStudy/SchoolAgainStudyBusinessLogic/BusinessLogic/ChartLogic.cs index bdee914..25ec880 100644 --- a/SchoolAgainStudy/SchoolAgainStudyBusinessLogic/BusinessLogic/ChartLogic.cs +++ b/SchoolAgainStudy/SchoolAgainStudyBusinessLogic/BusinessLogic/ChartLogic.cs @@ -157,5 +157,28 @@ namespace SchoolAgainStudyBusinessLogic.BusinessLogic var actList = list.Select(g => new TopersViewModel { Name = _student.ReadElement(new StudentSearchModel { Id = g.Key }).Name, Count = g.Value }).ToList(); return actList; } - } + public List GetTopInterests(int StudentId) + { + var interests = _interest.ReadList(new InterestSearchModel { StudentId = StudentId }); + var products = _product.ReadList(new ProductSearchModel { StudentId = StudentId }); + var diyes = _diy.ReadList(new DiySearchModel { StudentId = StudentId }); + Dictionary list = new Dictionary(); + foreach(var interest in interests) + { + list.Add(interest, 0); + foreach(var product in products) + { + if (product.ProductInterests.ContainsKey(interest.Id)) + list[interest] += 1; + } + foreach (var diy in diyes) + { + if (diy.DiyInterests.ContainsKey(interest.Id)) + list[interest] += 1; + } + } + var actList = list.Select(g => new TopersViewModel { Name = g.Key.Title, Count = g.Value }).ToList(); + return actList; + } + } } diff --git a/SchoolAgainStudy/SchoolAgainStudyContracts/BusinessLogicContracts/IChartLogic.cs b/SchoolAgainStudy/SchoolAgainStudyContracts/BusinessLogicContracts/IChartLogic.cs index 39dc5c5..c945045 100644 --- a/SchoolAgainStudy/SchoolAgainStudyContracts/BusinessLogicContracts/IChartLogic.cs +++ b/SchoolAgainStudy/SchoolAgainStudyContracts/BusinessLogicContracts/IChartLogic.cs @@ -11,7 +11,8 @@ namespace SchoolAgainStudyContracts.BusinessLogicContracts { public (int Products, int Diyes) GetDifferenceInCount(int StudentId); public List GetActivitys(int StudentId); - public List GetTopMaterials(int TeacherId); + public List GetTopInterests(int StudentId); + public List GetTopMaterials(int TeacherId); public List GetTopStudents(int TeacherId); } } diff --git a/SchoolAgainStudy/StudentWebClient/Controllers/HomeController.cs b/SchoolAgainStudy/StudentWebClient/Controllers/HomeController.cs index b983b0b..098c9d0 100644 --- a/SchoolAgainStudy/StudentWebClient/Controllers/HomeController.cs +++ b/SchoolAgainStudy/StudentWebClient/Controllers/HomeController.cs @@ -517,6 +517,20 @@ namespace StudentWebClient.Controllers NullValueHandling = NullValueHandling.Ignore}); return View(); } + [HttpGet] + public IActionResult TopInterests() + { + if (APIClient.Student == null) + { + return Redirect("~/Home/Enter"); + } + ViewBag.DataPoints = JsonConvert.SerializeObject(_chart.GetTopInterests(APIClient.Student.Id), + new JsonSerializerSettings() + { + NullValueHandling = NullValueHandling.Ignore + }); + return View(); + } } diff --git a/SchoolAgainStudy/StudentWebClient/Views/Home/ActivityCharts.cshtml b/SchoolAgainStudy/StudentWebClient/Views/Home/ActivityCharts.cshtml index b03f6e7..195f48c 100644 --- a/SchoolAgainStudy/StudentWebClient/Views/Home/ActivityCharts.cshtml +++ b/SchoolAgainStudy/StudentWebClient/Views/Home/ActivityCharts.cshtml @@ -6,28 +6,28 @@ for (var i = 0; i < result.length; i++) { dataPoints.push({ label: result[i].dateOf, y: result[i].count }); } - window.onload = function () { - var chart = new CanvasJS.Chart("chartContainer", { + window.onload = function () { + var chart = new CanvasJS.Chart("chartContainer", { theme: "theme2", animationEnabled: true, title: { - text: "Отслеживание работы за послдений месяц" + text: "Отслеживание работы за послдений месяц" }, data: [ - { - // change type to bar, line, area, pie, etc. + { + // change type to bar, line, area, pie, etc. type: "column", - - dataPoints: dataPoints - } - ] - }); - chart.render(); - }; - + dataPoints: dataPoints + } + ] + }); + chart.render(); + + }; + -
-
- +
+
+ \ No newline at end of file diff --git a/SchoolAgainStudy/StudentWebClient/Views/Home/TopInterests.cshtml b/SchoolAgainStudy/StudentWebClient/Views/Home/TopInterests.cshtml new file mode 100644 index 0000000..fac8172 --- /dev/null +++ b/SchoolAgainStudy/StudentWebClient/Views/Home/TopInterests.cshtml @@ -0,0 +1,33 @@ +@using SchoolAgainStudyContracts.ViewModel; +@model List + + +
+
+ + \ No newline at end of file diff --git a/SchoolAgainStudy/StudentWebClient/Views/Shared/_Layout.cshtml b/SchoolAgainStudy/StudentWebClient/Views/Shared/_Layout.cshtml index fe0f7f6..b6ebff7 100644 --- a/SchoolAgainStudy/StudentWebClient/Views/Shared/_Layout.cshtml +++ b/SchoolAgainStudy/StudentWebClient/Views/Shared/_Layout.cshtml @@ -51,6 +51,9 @@ +