From 8f1fbeadb243a486dce7bbfd9b932a551fd36350 Mon Sep 17 00:00:00 2001 From: Michael Date: Thu, 23 Mar 2017 09:47:22 -0400 Subject: [PATCH] Display newest user in right navbar --- Project-Unite/ACL.cs | 10 ++++++++++ Project-Unite/Controllers/HomeController.cs | 1 + Project-Unite/Models/HomeViewModel.cs | 12 ++++++++++++ Project-Unite/Project-Unite.csproj | 1 + Project-Unite/Views/Shared/_Layout.cshtml | 8 +++++++- 5 files changed, 31 insertions(+), 1 deletion(-) create mode 100644 Project-Unite/Models/HomeViewModel.cs diff --git a/Project-Unite/ACL.cs b/Project-Unite/ACL.cs index c0a0894..4b4e6b0 100644 --- a/Project-Unite/ACL.cs +++ b/Project-Unite/ACL.cs @@ -13,6 +13,16 @@ namespace Project_Unite { public static class ACL { + public static IHtmlString NewestUser(this HtmlHelper hpr) + { + var db = new ApplicationDbContext(); + var user = db.Users.OrderByDescending(x => x.JoinedAt).FirstOrDefault(); + if (user == null) + return hpr.Raw(@"No new users"); + else + return hpr.Raw("Our newest user, " + user.DisplayName + ""); + } + public static IHtmlString Markdown(this HtmlHelper hpr, string md) { return hpr.Raw(CommonMark.CommonMarkConverter.Convert(hpr.Encode(md))); diff --git a/Project-Unite/Controllers/HomeController.cs b/Project-Unite/Controllers/HomeController.cs index a3a8f7f..5a1553f 100644 --- a/Project-Unite/Controllers/HomeController.cs +++ b/Project-Unite/Controllers/HomeController.cs @@ -11,6 +11,7 @@ public class HomeController : Controller { public ActionResult Index() { + return View(); } diff --git a/Project-Unite/Models/HomeViewModel.cs b/Project-Unite/Models/HomeViewModel.cs new file mode 100644 index 0000000..d9d98bb --- /dev/null +++ b/Project-Unite/Models/HomeViewModel.cs @@ -0,0 +1,12 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Web; + +namespace Project_Unite.Models +{ + public class HomeViewModel + { + public ApplicationUser NewestUser { get; set; } + } +} \ No newline at end of file diff --git a/Project-Unite/Project-Unite.csproj b/Project-Unite/Project-Unite.csproj index 88d1527..100b767 100644 --- a/Project-Unite/Project-Unite.csproj +++ b/Project-Unite/Project-Unite.csproj @@ -405,6 +405,7 @@ + diff --git a/Project-Unite/Views/Shared/_Layout.cshtml b/Project-Unite/Views/Shared/_Layout.cshtml index 0e64010..932593f 100644 --- a/Project-Unite/Views/Shared/_Layout.cshtml +++ b/Project-Unite/Views/Shared/_Layout.cshtml @@ -3,7 +3,7 @@ - @ViewBag.Title - My ASP.NET Application + @ViewBag.Title • Project: Unite @Styles.Render("~/Content/css") @Styles.Render("~/Content/bootstrap-theme.css") @Styles.Render("~/Content/Site.css") @@ -75,6 +75,12 @@ }
+
+
+

Welcome to Project: Unite! Things are a bit barren right now and not a lot of stuff is implemented - but feel free to explore!

+
+
+ @if (!ACL.UserEmailConfirmed(User.Identity.Name)) {