Advertisement
Guest User

Untitled

a guest
Jun 20th, 2019
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.94 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel.DataAnnotations.Schema;
  4. using System.Linq;
  5. using System.Text;
  6. using System.Threading.Tasks;
  7. using CommunityProject.Utilities;
  8.  
  9. namespace CommunityProject.Data.Models
  10. {
  11. public enum CanCreateTopic
  12. {
  13. Admin,
  14. Moderator,
  15. All
  16. }
  17.  
  18. public partial class Forum : Entity
  19. {
  20. public Forum()
  21. {
  22. CanCreateTopicId = CanCreateTopic.All;
  23. IsDeleted = false;
  24. CDate = DateTime.UtcNow;
  25. IsNewsForum = false;
  26. }
  27.  
  28. [Index("IX_Forum_ID")]
  29. public int Id { get; set; }
  30.  
  31. //Foreign Keys
  32.  
  33. [Index("IX_Forum_CategoryID")]
  34. public int CategoryId { get; set; }
  35.  
  36. public int CUserId { get; set; }
  37.  
  38. public int? EUserId { get; set; }
  39.  
  40. //Content
  41.  
  42. /// <summary>
  43. /// The icon to display on the forum
  44. /// </summary>
  45. public string Icon { get; set; }
  46.  
  47. public string Name { get; set; }
  48.  
  49. public string Description { get; set; }
  50.  
  51. public bool IsLocked { get; set; }
  52.  
  53. public CanCreateTopic CanCreateTopicId { get; set; }
  54.  
  55. public int SortOrder { get; set; }
  56.  
  57. public bool IsDeleted { get; set; }
  58.  
  59. /// <summary>
  60. /// If this is checked, the topics created here will be visible on the Home Page.
  61. /// </summary>
  62. public bool IsNewsForum { get; set; }
  63.  
  64. public DateTime CDate { get; set; }
  65.  
  66. public DateTime? EDate { get; set; }
  67.  
  68. //Virtuals
  69.  
  70. public virtual User CreatedUser { get; set; }
  71.  
  72. public virtual User EditedUser { get; set; }
  73.  
  74. public virtual Category Category { get; set; }
  75.  
  76. public virtual IList<Topic> Topics { get; set; }
  77.  
  78. public bool UserCanCreateTopics(string forumUserType)
  79. {
  80. switch (CanCreateTopicId)
  81. {
  82. case CanCreateTopic.All:
  83. return true;
  84. case CanCreateTopic.Moderator:
  85. switch (forumUserType)
  86. {
  87. case AppConstants.AdministratorTypeName:
  88. case AppConstants.ModeratorTypeName:
  89. case AppConstants.OwnerTypeName:
  90. case AppConstants.SystemTypeName:
  91. return true;
  92. default:
  93. return false;
  94. }
  95. case CanCreateTopic.Admin:
  96. switch (forumUserType)
  97. {
  98. case AppConstants.AdministratorTypeName:
  99. case AppConstants.OwnerTypeName:
  100. case AppConstants.SystemTypeName:
  101. return true;
  102. default:
  103. return false;
  104. }
  105. default:
  106. return false;
  107.  
  108. }
  109. }
  110. }
  111. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement