Display newest user in right navbar

This commit is contained in:
Michael 2017-03-23 09:47:22 -04:00
parent b0b5c4163c
commit 8f1fbeadb2
5 changed files with 31 additions and 1 deletions

View file

@ -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(@"<a href=""#"">No new users</a>");
else
return hpr.Raw("<a href=\"/Profiles/ViewProfile/" + user.DisplayName + "\">Our newest user, <strong>" + user.DisplayName + "</strong></a>");
}
public static IHtmlString Markdown(this HtmlHelper hpr, string md)
{
return hpr.Raw(CommonMark.CommonMarkConverter.Convert(hpr.Encode(md)));

View file

@ -11,6 +11,7 @@ public class HomeController : Controller
{
public ActionResult Index()
{
return View();
}

View file

@ -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; }
}
}

View file

@ -405,6 +405,7 @@
<Compile Include="Models\AdminViewModels.cs" />
<Compile Include="Models\ForumCategory.cs" />
<Compile Include="Models\ForumViewModels.cs" />
<Compile Include="Models\HomeViewModel.cs" />
<Compile Include="Models\IdentityModels.cs" />
<Compile Include="Models\ManageViewModels.cs" />
<Compile Include="Models\Role.cs" />

View file

@ -3,7 +3,7 @@
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>@ViewBag.Title - My ASP.NET Application</title>
<title>@ViewBag.Title &bull; Project: Unite</title>
@Styles.Render("~/Content/css")
@Styles.Render("~/Content/bootstrap-theme.css")
@Styles.Render("~/Content/Site.css")
@ -75,6 +75,12 @@
}
<div class="container clearfix body-content">
<div class="panel panel-success">
<div class="panel-body">
<p><span class="glyphicon glyphicon-exclamation-sign"></span> <strong>Welcome to Project: Unite!</strong> Things are a bit barren right now and not a lot of stuff is implemented - but feel free to explore!</p>
</div>
</div>
@if (!ACL.UserEmailConfirmed(User.Identity.Name))
{
<div class="panel panel-warning">