Home view
[wsti_pai.git] / Projects / Controllers / HomeController.cs
index 3f1f379839427ecf36ec15a21364e6310fbbd059..a55e6d23f575c923c252c1642ca5b0471f2fe9ed 100644 (file)
@@ -3,20 +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
     {
-        public ActionResult Index()
-        {
-            return View();
-        }
+        private ProjectsDBEntities db = new ProjectsDBEntities();
 
-        public ActionResult About()
+        public ActionResult Index()
         {
-            ViewBag.Message = "Your application description page.";
+            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();
         }