summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Project-Unite/ACL.cs5
-rw-r--r--Project-Unite/Models/IdentityModels.cs18
-rw-r--r--Project-Unite/Views/Shared/_LoginPartial.cshtml1
3 files changed, 24 insertions, 0 deletions
diff --git a/Project-Unite/ACL.cs b/Project-Unite/ACL.cs
index 88e2fc2..ca356f9 100644
--- a/Project-Unite/ACL.cs
+++ b/Project-Unite/ACL.cs
@@ -67,6 +67,11 @@ namespace Project_Unite
return hpr.Raw(CommonMark.CommonMarkConverter.Convert(hpr.Encode(md)));
}
+ public static int UnreadPostsCount(string username)
+ {
+ return new ApplicationDbContext().Users.FirstOrDefault(x => x.UserName == username).UnreadPosts.Length;
+ }
+
public static bool IsFollowed(string you, string fId)
{
var db = new ApplicationDbContext();
diff --git a/Project-Unite/Models/IdentityModels.cs b/Project-Unite/Models/IdentityModels.cs
index bb55d50..6cfb821 100644
--- a/Project-Unite/Models/IdentityModels.cs
+++ b/Project-Unite/Models/IdentityModels.cs
@@ -39,6 +39,16 @@ namespace Project_Unite.Models
}
+ public ForumPost[] UnreadPosts
+ {
+ get
+ {
+ var db = new ApplicationDbContext();
+ var posts = db.ForumPosts.Where(x => db.ReadPosts.FirstOrDefault(y => y.UserId == this.Id && y.PostId == x.Id) == null);
+ return posts.ToArray();
+ }
+ }
+
public Role HighestRole
{
get
@@ -204,6 +214,7 @@ namespace Project_Unite.Models
return new ApplicationDbContext();
}
+ public DbSet<ReadPost> ReadPosts { get; set; }
public DbSet<Download> Downloads { get; set; }
public DbSet<DatabaseBackup> Backups { get; set; }
public DbSet<AssetBackup> AssetBackups { get; set; }
@@ -230,6 +241,13 @@ namespace Project_Unite.Models
public DbSet<View> Views { get; set; }
}
+ public class ReadPost
+ {
+ public string Id { get; set; }
+ public string PostId { get; set; }
+ public string UserId { get; set; }
+ }
+
public class UserPost
{
public string Id { get; set; }
diff --git a/Project-Unite/Views/Shared/_LoginPartial.cshtml b/Project-Unite/Views/Shared/_LoginPartial.cshtml
index 3e20d00..8f7aabf 100644
--- a/Project-Unite/Views/Shared/_LoginPartial.cshtml
+++ b/Project-Unite/Views/Shared/_LoginPartial.cshtml
@@ -7,6 +7,7 @@
<ul class="nav navbar-nav navbar-right" style="margin-right:15px;">
<li>@Html.NewestUser()</li>
+ <li><a href="@Url.Action("ViewUnread", "Forum")"><span class="glyphicon glyphicon-star-empty"></span> @ACL.UnreadPostsCount(User.Identity.Name) unread posts</a></li>
<li class="dropdown"><a href="#" data-toggle="dropdown" class="dropdown-toggle"><span class="glyphicon glyphicon-bullhorn"></span> @Html.NotificationCount(User.Identity.GetUserId())</a>
<ul class="dropdown-menu">
<li class="dropdown-header">Notifications (@Html.NotificationCount(User.Identity.Name) unread)</li>