mirror of
https://github.com/lempamo/Project-Unite.git
synced 2025-04-27 10:40:23 +00:00
Unread posts backend.
This commit is contained in:
parent
fd5302fca4
commit
93734dd552
3 changed files with 24 additions and 0 deletions
|
@ -67,6 +67,11 @@ namespace Project_Unite
|
||||||
return hpr.Raw(CommonMark.CommonMarkConverter.Convert(hpr.Encode(md)));
|
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)
|
public static bool IsFollowed(string you, string fId)
|
||||||
{
|
{
|
||||||
var db = new ApplicationDbContext();
|
var db = new ApplicationDbContext();
|
||||||
|
|
|
@ -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
|
public Role HighestRole
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
|
@ -204,6 +214,7 @@ namespace Project_Unite.Models
|
||||||
return new ApplicationDbContext();
|
return new ApplicationDbContext();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public DbSet<ReadPost> ReadPosts { get; set; }
|
||||||
public DbSet<Download> Downloads { get; set; }
|
public DbSet<Download> Downloads { get; set; }
|
||||||
public DbSet<DatabaseBackup> Backups { get; set; }
|
public DbSet<DatabaseBackup> Backups { get; set; }
|
||||||
public DbSet<AssetBackup> AssetBackups { get; set; }
|
public DbSet<AssetBackup> AssetBackups { get; set; }
|
||||||
|
@ -230,6 +241,13 @@ namespace Project_Unite.Models
|
||||||
public DbSet<View> Views { get; set; }
|
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 class UserPost
|
||||||
{
|
{
|
||||||
public string Id { get; set; }
|
public string Id { get; set; }
|
||||||
|
|
|
@ -7,6 +7,7 @@
|
||||||
|
|
||||||
<ul class="nav navbar-nav navbar-right" style="margin-right:15px;">
|
<ul class="nav navbar-nav navbar-right" style="margin-right:15px;">
|
||||||
<li>@Html.NewestUser()</li>
|
<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>
|
<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">
|
<ul class="dropdown-menu">
|
||||||
<li class="dropdown-header">Notifications (@Html.NotificationCount(User.Identity.Name) unread)</li>
|
<li class="dropdown-header">Notifications (@Html.NotificationCount(User.Identity.Name) unread)</li>
|
||||||
|
|
Loading…
Add table
Reference in a new issue