Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.ComponentModel.DataAnnotations.Schema;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using CommunityProject.Utilities;
- namespace CommunityProject.Data.Models
- {
- public enum CanCreateTopic
- {
- Admin,
- Moderator,
- All
- }
- public partial class Forum : Entity
- {
- public Forum()
- {
- CanCreateTopicId = CanCreateTopic.All;
- IsDeleted = false;
- CDate = DateTime.UtcNow;
- IsNewsForum = false;
- }
- [Index("IX_Forum_ID")]
- public int Id { get; set; }
- //Foreign Keys
- [Index("IX_Forum_CategoryID")]
- public int CategoryId { get; set; }
- public int CUserId { get; set; }
- public int? EUserId { get; set; }
- //Content
- /// <summary>
- /// The icon to display on the forum
- /// </summary>
- public string Icon { get; set; }
- public string Name { get; set; }
- public string Description { get; set; }
- public bool IsLocked { get; set; }
- public CanCreateTopic CanCreateTopicId { get; set; }
- public int SortOrder { get; set; }
- public bool IsDeleted { get; set; }
- /// <summary>
- /// If this is checked, the topics created here will be visible on the Home Page.
- /// </summary>
- public bool IsNewsForum { get; set; }
- public DateTime CDate { get; set; }
- public DateTime? EDate { get; set; }
- //Virtuals
- public virtual User CreatedUser { get; set; }
- public virtual User EditedUser { get; set; }
- public virtual Category Category { get; set; }
- public virtual IList<Topic> Topics { get; set; }
- public bool UserCanCreateTopics(string forumUserType)
- {
- switch (CanCreateTopicId)
- {
- case CanCreateTopic.All:
- return true;
- case CanCreateTopic.Moderator:
- switch (forumUserType)
- {
- case AppConstants.AdministratorTypeName:
- case AppConstants.ModeratorTypeName:
- case AppConstants.OwnerTypeName:
- case AppConstants.SystemTypeName:
- return true;
- default:
- return false;
- }
- case CanCreateTopic.Admin:
- switch (forumUserType)
- {
- case AppConstants.AdministratorTypeName:
- case AppConstants.OwnerTypeName:
- case AppConstants.SystemTypeName:
- return true;
- default:
- return false;
- }
- default:
- return false;
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement