summaryrefslogtreecommitdiff
path: root/Project-Unite/ACL.cs
diff options
context:
space:
mode:
authorMichael <[email protected]>2017-03-24 15:31:22 -0400
committerMichael <[email protected]>2017-03-24 15:31:22 -0400
commit7c76a963c8e2bc891c38f664c60d9daac31822ee (patch)
treec118a8c19a993988a5a11a9c8d97eab3e97bfb52 /Project-Unite/ACL.cs
parenteae28fa3d278c91f2b42b8420db2dd5704d5a049 (diff)
downloadproject-unite-7c76a963c8e2bc891c38f664c60d9daac31822ee.tar.gz
project-unite-7c76a963c8e2bc891c38f664c60d9daac31822ee.tar.bz2
project-unite-7c76a963c8e2bc891c38f664c60d9daac31822ee.zip
Notification dropdown in navbar is done.
Diffstat (limited to 'Project-Unite/ACL.cs')
-rw-r--r--Project-Unite/ACL.cs30
1 files changed, 30 insertions, 0 deletions
diff --git a/Project-Unite/ACL.cs b/Project-Unite/ACL.cs
index 77e6f1d..97131b0 100644
--- a/Project-Unite/ACL.cs
+++ b/Project-Unite/ACL.cs
@@ -8,6 +8,7 @@ using System.Web.Mvc;
using System.Diagnostics;
using System.Web.Mvc.Html;
using System.Data.Entity;
+using System.Text;
namespace Project_Unite
{
@@ -32,6 +33,35 @@ namespace Project_Unite
return hpr.Raw("<a href=\"/Profiles/ViewProfile/" + user.DisplayName + "\"><span class=\"glyphicon glyphicon-star\"></span> Our newest user, <strong>" + user.DisplayName + "</strong></a>");
}
+ public static IHtmlString GetLatestNotifications(this HtmlHelper hpr, string userName)
+ {
+ var db = new ApplicationDbContext();
+ var user = db.Users.FirstOrDefault(x => x.UserName == userName);
+ if (user == null)
+ return hpr.Raw("");
+ var notesOrdered = user.Notifications.Where(x => x.IsRead == false).OrderByDescending(x => x.Timestamp).ToArray();
+ StringBuilder builder = new StringBuilder();
+
+ for (int i = 0; i < notesOrdered.Length && i < 5; i++)
+ {
+ builder.AppendLine("<li><a href=\"" + notesOrdered[i].ActionUrl + "\">");
+ //Avatar holder start:
+ builder.AppendLine("<div style=\"width:128px;height:128px;display:inline-block;\">");
+ //Avatar
+ builder.AppendLine("<img src=\"" + notesOrdered[i].AvatarUrl + "\" width=\"128\" height=\"128\"/>");
+ //Avatar holder end:
+ builder.AppendLine("</div>");
+
+ //Notification title.
+ builder.AppendLine("<strong>" + notesOrdered[i].Title + "</strong><br/>");
+ //Contents.
+ builder.AppendLine("<p>" + notesOrdered[i].Description + "</p>");
+
+ builder.AppendLine("</a></li>");
+ }
+ return hpr.Raw(builder.ToString());
+ }
+
public static IHtmlString Markdown(this HtmlHelper hpr, string md)
{
return hpr.Raw(CommonMark.CommonMarkConverter.Convert(hpr.Encode(md)));