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.Diagnostics;
using System.Web.Mvc.Html;
using System.Data.Entity;
+using System.Text;
namespace Project_Unite
{
@@ -32,6 +33,35 @@ public static IHtmlString NewestUser(this HtmlHelper hpr)
return hpr.Raw(" Our newest user, " + user.DisplayName + "");
}
+ 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("
");
+ //Avatar holder start:
+ builder.AppendLine("");
+ //Avatar
+ builder.AppendLine("
");
+ //Avatar holder end:
+ builder.AppendLine("
");
+
+ //Notification title.
+ builder.AppendLine("" + notesOrdered[i].Title + "
");
+ //Contents.
+ builder.AppendLine("" + notesOrdered[i].Description + "
");
+
+ builder.AppendLine("");
+ }
+ return hpr.Raw(builder.ToString());
+ }
+
public static IHtmlString Markdown(this HtmlHelper hpr, string md)
{
return hpr.Raw(CommonMark.CommonMarkConverter.Convert(hpr.Encode(md)));
diff --git a/Project-Unite/Models/Notification.cs b/Project-Unite/Models/Notification.cs
index dd13e5b..5870d76 100644
--- a/Project-Unite/Models/Notification.cs
+++ b/Project-Unite/Models/Notification.cs
@@ -12,6 +12,9 @@ public class Notification
public string Discriminator { get; set; }
public DateTime Timestamp { get; set; }
public bool IsRead { get; set; }
-
+ public string AvatarUrl { get; set; }
+ public string Title { get; set; }
+ public string Description { get; set; }
+ public string ActionUrl { get; set; }
}
}
\ No newline at end of file
diff --git a/Project-Unite/Views/Shared/_LoginPartial.cshtml b/Project-Unite/Views/Shared/_LoginPartial.cshtml
index 7abc0d1..3e20d00 100644
--- a/Project-Unite/Views/Shared/_LoginPartial.cshtml
+++ b/Project-Unite/Views/Shared/_LoginPartial.cshtml
@@ -7,7 +7,13 @@