summaryrefslogtreecommitdiff
path: root/Project-Unite/ACL.cs
diff options
context:
space:
mode:
authorMichael <[email protected]>2017-03-27 16:11:39 -0400
committerMichael <[email protected]>2017-03-27 16:11:39 -0400
commit32e2eecdd4904383df6c377cb3ea64f8f0a8f1e4 (patch)
treef2a465f61c7ebdc971cff20e905a749696f9f253 /Project-Unite/ACL.cs
parent93734dd552b9c95da23b517ea1f65854f22c68f6 (diff)
downloadproject-unite-32e2eecdd4904383df6c377cb3ea64f8f0a8f1e4.tar.gz
project-unite-32e2eecdd4904383df6c377cb3ea64f8f0a8f1e4.tar.bz2
project-unite-32e2eecdd4904383df6c377cb3ea64f8f0a8f1e4.zip
Finish unread posts
Diffstat (limited to 'Project-Unite/ACL.cs')
-rw-r--r--Project-Unite/ACL.cs29
1 files changed, 29 insertions, 0 deletions
diff --git a/Project-Unite/ACL.cs b/Project-Unite/ACL.cs
index ca356f9..36eba6e 100644
--- a/Project-Unite/ACL.cs
+++ b/Project-Unite/ACL.cs
@@ -62,6 +62,35 @@ namespace Project_Unite
return hpr.Raw(builder.ToString());
}
+ public static bool IsUnlisted(string topicId)
+ {
+ return new ApplicationDbContext().ForumTopics.FirstOrDefault(x => x.Id == topicId).IsUnlisted;
+ }
+
+ public static bool IsUnread(string user, string postId)
+ {
+ var db = new ApplicationDbContext();
+ var u = db.Users.FirstOrDefault(x => x.Id == user);
+ return u.UnreadPosts.FirstOrDefault(x => x.Id == postId) != null;
+ }
+
+ public static void MarkRead(string userId, string postId)
+ {
+ var mark = new ReadPost();
+ mark.Id = Guid.NewGuid().ToString();
+ mark.PostId = postId;
+ mark.UserId = userId;
+ var db = new ApplicationDbContext();
+ db.ReadPosts.Add(mark);
+ db.SaveChanges();
+ }
+
+ public static IHtmlString TopicLinkFor(this HtmlHelper hpr, string topicId)
+ {
+ var topic = new ApplicationDbContext().ForumTopics.FirstOrDefault(x => x.Id == topicId);
+ return hpr.ActionLink(topic.Subject, "ViewTopic", "Forum", new { id = topic.Discriminator }, null);
+ }
+
public static IHtmlString Markdown(this HtmlHelper hpr, string md)
{
return hpr.Raw(CommonMark.CommonMarkConverter.Convert(hpr.Encode(md)));