From: Rafał Długołęcki Date: Fri, 12 Feb 2016 03:13:55 +0000 (+0100) Subject: Added user activity list X-Git-Url: https://git.dlugolecki.net.pl/?a=commitdiff_plain;h=cff1b559dd30993fc4cdd7ee9eeea3831866b3f6;p=wsti_pai.git Added user activity list --- 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")