From 7e54c9b3fad48c7bce1134f7937924f120f1999c Mon Sep 17 00:00:00 2001 From: Michael Date: Wed, 17 May 2017 09:52:57 -0400 Subject: More fixes, specifically with forum --- Project-Unite/Models/ForumCategory.cs | 50 ++++++++++++++++++++--------------- 1 file changed, 29 insertions(+), 21 deletions(-) (limited to 'Project-Unite/Models/ForumCategory.cs') diff --git a/Project-Unite/Models/ForumCategory.cs b/Project-Unite/Models/ForumCategory.cs index da5a9c9..52e184e 100644 --- a/Project-Unite/Models/ForumCategory.cs +++ b/Project-Unite/Models/ForumCategory.cs @@ -39,28 +39,12 @@ namespace Project_Unite.Models public virtual string Parent { get; set; } - public ForumPermission[] Permissions { get - { - var db = new ApplicationDbContext(); - return db.ForumPermissions.Where(x => x.CategoryId == this.Id).ToArray(); - } - } - } - - public class ForumPermission - { - [Key] - public string Id { get; set; } - - [Required] - public string CategoryId { get; set; } - - [Required] - public string RoleId { get; set; } + public int AdminPermission { get; set; } + public int DeveloperPermission { get; set; } + public int ModeratorPermission { get; set; } + public int MemberPermission { get; set; } - [Required] - [EnumDataType(typeof(PermissionPreset))] - public PermissionPreset Permissions { get; set; } + public bool VisibleToGuests { get; set; } } public class ForumPost @@ -124,8 +108,32 @@ namespace Project_Unite.Models public bool IsLocked { get; set; } + public int Priority + { + get + { + int priority = 0; + if (IsSticky) + priority = 1; + if (IsAnnounce) + priority = 2; + if (IsSticky && IsAnnounce) + priority = 3; + return priority; + } + } + public DateTime StartedAt { get; set; } public string Subject { get; set; } + public bool ShouldShow + { + get + { + if (IsUnlisted == true) + return HttpContext.Current.User?.Identity?.IsModerator() == true; + return true; + } + } public string AuthorId { get; set; } public bool IsSticky { get; set; } public bool IsAnnounce { get; set; } -- cgit v1.2.3