From cff1b559dd30993fc4cdd7ee9eeea3831866b3f6 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Rafa=C5=82=20D=C5=82ugo=C5=82=C4=99cki?= Date: Fri, 12 Feb 2016 04:13:55 +0100 Subject: [PATCH] Added user activity list --- Projects/Controllers/ActivityController.cs | 28 ++++++++++++++++++++++ Projects/Controllers/ActivityResult.cs | 8 +++++++ Projects/Projects.csproj | 3 +++ Projects/Views/Shared/_Layout.cshtml | 1 + 4 files changed, 40 insertions(+) create mode 100644 Projects/Controllers/ActivityController.cs create mode 100644 Projects/Controllers/ActivityResult.cs diff --git a/Projects/Controllers/ActivityController.cs b/Projects/Controllers/ActivityController.cs new file mode 100644 index 0000000..e98c679 --- /dev/null +++ b/Projects/Controllers/ActivityController.cs @@ -0,0 +1,28 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Web; +using System.Web.Mvc; +using Projects.Models; + +namespace Projects.Controllers +{ + public class ActivityController : Controller + { + private ProjectsDBEntities db = new ProjectsDBEntities(); + + // GET: Activity + public ActionResult Index() + { + var results = (from pt in db.ProjectTasks + join ts in db.TaskStatuses on pt.task_status_id equals ts.id + where ts.status == "Done" + group pt.User by pt.User.id into g + join u in db.Users on g.Key equals u.id + select new ActivityResult { user = u.login, count = g.Count() }) + .ToList(); + ViewBag.results = results; + return View(); + } + } +} \ No newline at end of file diff --git a/Projects/Controllers/ActivityResult.cs b/Projects/Controllers/ActivityResult.cs new file mode 100644 index 0000000..d13f52d --- /dev/null +++ b/Projects/Controllers/ActivityResult.cs @@ -0,0 +1,8 @@ +namespace Projects +{ + public class ActivityResult + { + public int count { get; set; } + public string user { get; set; } + } +} \ No newline at end of file diff --git a/Projects/Projects.csproj b/Projects/Projects.csproj index db60767..9efa3cf 100644 --- a/Projects/Projects.csproj +++ b/Projects/Projects.csproj @@ -198,6 +198,8 @@ + + @@ -331,6 +333,7 @@ + diff --git a/Projects/Views/Shared/_Layout.cshtml b/Projects/Views/Shared/_Layout.cshtml index 36e4ac3..987ded9 100644 --- a/Projects/Views/Shared/_Layout.cshtml +++ b/Projects/Views/Shared/_Layout.cshtml @@ -25,6 +25,7 @@
  • @Html.ActionLink("Kontakt", "Contact", "Home")
  • @Html.ActionLink("Lista projektów", "Index", "Projects")
  • @Html.ActionLink("Lista zadań", "Index", "ProjectTasks")
  • +
  • @Html.ActionLink("Aktywność użytkowników", "Index", "Activity")
  • @Html.Partial("_LoginPartial") -- 2.30.2