Added user activity list
authorRafał Długołęcki <dlugolecki.rafal@gmail.com>
Fri, 12 Feb 2016 03:13:55 +0000 (04:13 +0100)
committerRafał Długołęcki <dlugolecki.rafal@gmail.com>
Fri, 12 Feb 2016 03:13:55 +0000 (04:13 +0100)
Projects/Controllers/ActivityController.cs [new file with mode: 0644]
Projects/Controllers/ActivityResult.cs [new file with mode: 0644]
Projects/Projects.csproj
Projects/Views/Shared/_Layout.cshtml

diff --git a/Projects/Controllers/ActivityController.cs b/Projects/Controllers/ActivityController.cs
new file mode 100644 (file)
index 0000000..e98c679
--- /dev/null
@@ -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 (file)
index 0000000..d13f52d
--- /dev/null
@@ -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
index db6076717fcc22dce0d3a2b7b0bd0873527bd085..9efa3cfa82f3c4432ed6f084143c9b3ec425bb04 100644 (file)
     <Compile Include="App_Start\RouteConfig.cs" />
     <Compile Include="App_Start\Startup.Auth.cs" />
     <Compile Include="Controllers\AccountController.cs" />
+    <Compile Include="Controllers\ActivityController.cs" />
+    <Compile Include="Controllers\ActivityResult.cs" />
     <Compile Include="Controllers\HomeController.cs" />
     <Compile Include="Controllers\ManageController.cs" />
     <Compile Include="Controllers\ProjectTasksController.cs" />
     <Content Include="Views\ProjectTasks\Details.cshtml" />
     <Content Include="Views\ProjectTasks\Edit.cshtml" />
     <Content Include="Views\ProjectTasks\Index.cshtml" />
+    <Content Include="Views\Activity\Index.cshtml" />
   </ItemGroup>
   <ItemGroup>
     <Folder Include="App_Data\" />
index 36e4ac36d14a12d05cf00e4d7e8b33a679bca22b..987ded9ca43d4071c56af39745fb1f9230653b58 100644 (file)
@@ -25,6 +25,7 @@
                     <li>@Html.ActionLink("Kontakt", "Contact", "Home")</li>
                     <li>@Html.ActionLink("Lista projektów", "Index", "Projects")</li>
                     <li>@Html.ActionLink("Lista zadań", "Index", "ProjectTasks")</li>
+                    <li>@Html.ActionLink("Aktywność użytkowników", "Index", "Activity")</li>
                 </ul>
                 @Html.Partial("_LoginPartial")
             </div>