From f03e98751aea4094a7ee81ea7c59b03ab684080a 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 03:12:11 +0100 Subject: [PATCH] Home view --- Projects/Controllers/HomeController.cs | 15 +++++++++++++ Projects/Views/Home/Index.cshtml | 30 +++++++++++++++++++------- Projects/Views/Projects/Index.cshtml | 4 ++-- 3 files changed, 39 insertions(+), 10 deletions(-) diff --git a/Projects/Controllers/HomeController.cs b/Projects/Controllers/HomeController.cs index c5d394a..a55e6d2 100644 --- a/Projects/Controllers/HomeController.cs +++ b/Projects/Controllers/HomeController.cs @@ -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(); } diff --git a/Projects/Views/Home/Index.cshtml b/Projects/Views/Home/Index.cshtml index 15e47fb..2f60f33 100644 --- a/Projects/Views/Home/Index.cshtml +++ b/Projects/Views/Home/Index.cshtml @@ -9,17 +9,31 @@
-

Najnowsze projekty

-

- 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. -

+

Ostatnio edytowany projekt

+ + @if (ViewBag.recentProject != null) + { +

@Html.ActionLink((string)ViewBag.recentProject.name, "Details", "Projects")

+ @ViewBag.recentProject.description + przez: @ViewBag.recentProject.User.login + } + else { +

Brak

+ }

Pełna lista projektów »

-

Ostatnio zrobione zadania

-

NuGet is a free Visual Studio extension that makes it easy to add, remove, and update libraries and tools in Visual Studio projects.

+

Ostatnio edytowane zadanie

+ + @if (ViewBag.recentProject != null) + { +

@Html.ActionLink((string)ViewBag.recentTask.name, "Details", "ProjectTasks")

+ @ViewBag.recentTask.description + przez: @ViewBag.recentTask.User.login + } + else { +

Brak

+ }

Pełna lista zadań »

\ No newline at end of file diff --git a/Projects/Views/Projects/Index.cshtml b/Projects/Views/Projects/Index.cshtml index a565ad1..6600db1 100644 --- a/Projects/Views/Projects/Index.cshtml +++ b/Projects/Views/Projects/Index.cshtml @@ -1,13 +1,13 @@ @model IEnumerable @{ - ViewBag.Title = "Index"; + ViewBag.Title = "Lista projektów"; }

@ViewBag.Title

- @Html.ActionLink("Create New", "Create") + @Html.ActionLink("Stwórz nowy projekt", "Create")

-- 2.30.2