Home view
authorRafał Długołęcki <dlugolecki.rafal@gmail.com>
Fri, 12 Feb 2016 02:12:11 +0000 (03:12 +0100)
committerRafał Długołęcki <dlugolecki.rafal@gmail.com>
Fri, 12 Feb 2016 02:12:11 +0000 (03:12 +0100)
Projects/Controllers/HomeController.cs
Projects/Views/Home/Index.cshtml
Projects/Views/Projects/Index.cshtml

index c5d394a44686af0865849f1c343c3a01b181f012..a55e6d23f575c923c252c1642ca5b0471f2fe9ed 100644 (file)
@@ -3,13 +3,28 @@ using System.Collections.Generic;
 using System.Linq;
 using System.Web;
 using System.Web.Mvc;
+using Projects.Models;
 
 namespace Projects.Controllers
 {
     public class HomeController : Controller
     {
+        private ProjectsDBEntities db = new ProjectsDBEntities();
+
         public ActionResult Index()
         {
+            Project recentProject = (from d in db.Projects
+                                     orderby d.updated_at descending
+                                     select d)
+                .FirstOrDefault();
+            ProjectTask recentTask = (from d in db.ProjectTasks
+                                     orderby d.updated_at descending
+                                     select d)
+                .FirstOrDefault();
+
+            ViewBag.recentProject = recentProject;
+            ViewBag.recentTask = recentTask;
+            
             return View();
         }
 
index 15e47fb3ffce052075ec9eeeb8dca1781ec021fd..2f60f3368bd5a8bc84afa2b2b1044d1c01d6c894 100644 (file)
@@ -9,17 +9,31 @@
 
 <div class="row">
     <div class="col-md-6">
-        <h2>Najnowsze projekty</h2>
-        <p>
-            ASP.NET MVC gives you a powerful, patterns-based way to build dynamic websites that
-            enables a clean separation of concerns and gives you full control over markup
-            for enjoyable, agile development.
-        </p>
+        <h2>Ostatnio edytowany projekt</h2>
+        
+        @if (ViewBag.recentProject != null)
+        {
+            <p>@Html.ActionLink((string)ViewBag.recentProject.name, "Details", "Projects")</p>
+            <em>@ViewBag.recentProject.description</em>
+            <span>przez: @ViewBag.recentProject.User.login</span>
+        }
+        else {
+            <p>Brak</p>
+        }
         <p><a class="btn btn-default" href="@Url.Action("Index", "Projects")">Pełna lista projektów &raquo;</a></p>
     </div>
     <div class="col-md-6">
-        <h2>Ostatnio zrobione zadania</h2>
-        <p>NuGet is a free Visual Studio extension that makes it easy to add, remove, and update libraries and tools in Visual Studio projects.</p>
+        <h2>Ostatnio edytowane zadanie</h2>
+
+        @if (ViewBag.recentProject != null)
+        {
+            <p>@Html.ActionLink((string)ViewBag.recentTask.name, "Details", "ProjectTasks")</p>
+            <em>@ViewBag.recentTask.description</em>
+            <span>przez: @ViewBag.recentTask.User.login</span>
+        }
+        else {
+            <p>Brak</p>
+        }
         <p><a class="btn btn-default" href="@Url.Action("Index", "ProjectTasks")">Pełna lista zadań &raquo;</a></p>
     </div>
 </div>
\ No newline at end of file
index a565ad1bc86eaa5de338f1f9358d2e8f1b48736b..6600db1d463503e206f4b91d9ef8063aacad4e0a 100644 (file)
@@ -1,13 +1,13 @@
 @model IEnumerable<Projects.Models.Project>
 
 @{
-    ViewBag.Title = "Index";
+    ViewBag.Title = "Lista projektów";
 }
 
 <h2>@ViewBag.Title</h2>
 
 <p>
-    @Html.ActionLink("Create New", "Create")
+    @Html.ActionLink("Stwórz nowy projekt", "Create")
 </p>
 <table class="table">
     <tr>