コード例 #1
0
ファイル: Tag.cs プロジェクト: KallynGowdy/TheFlow
 /// <summary>
 /// Creates a new tag given the name, body of the wiki page and creator.
 /// </summary>
 /// <param name="name">The name of the tag to create.</param>
 /// <param name="wikiBody">The markdown body of the wiki page to create for the tag.</param>
 /// <param name="creator">The user who is the creator of the tag.</param>
 public Tag(string name, string wikiBody, User creator)
 {
     this.Name = name;
     if (wikiBody == null)
     {
         this.SetBody(string.Empty, creator);
     }
     else
     {
         this.SetBody(wikiBody, creator);
     }
     this.DateCreated = DateTime.UtcNow;
 }
コード例 #2
0
ファイル: Post.cs プロジェクト: KallynGowdy/TheFlow
 /// <summary>
 /// Creates a new post that was posted at DateTime.UtcNow, posted by the given author with the given body.
 /// </summary>
 /// <param name="author"></param>
 /// <param name="body"></param>
 protected Post(User author, string body)
 {
     this.Author = author;
     this.DatePosted = DateTime.UtcNow;
     this.Edits.Add(new Edit
     {
         Accepted = true,
         Editor = author,
         Body = body,
         DateChanged = DateTime.UtcNow,
         OriginalPost = this,
         PreviousVersion = null
     });
 }
コード例 #3
0
 /// <summary>
 /// Determines if the given user has (can use) the provided permission.
 /// </summary>
 /// <param name="user">The user to test against.</param>
 /// <param name="permission">The permission to test for access to.</param>
 /// <returns></returns>
 public static bool HasPermission(User user, UserPermission permission)
 {
     switch (permission)
     {
         case UserPermission.UpVote:
             return user.Reputation >= Settings.Permissions.UpVote;
         case UserPermission.DownVote:
             return user.Reputation >= Settings.Permissions.DownVote;
         case UserPermission.Flag:
             return user.Reputation >= Settings.Permissions.Flag;
         case UserPermission.Edit:
             return user.Reputation >= Settings.Permissions.Edit;
     }
     return false;
 }
コード例 #4
0
ファイル: Answer.cs プロジェクト: KallynGowdy/TheFlow
 public Answer(User author, string body, Question question, bool accepted = false)
     : base(author, body)
 {
     this.Question = question;
     this.Accepted = accepted;
 }
コード例 #5
0
ファイル: Tag.cs プロジェクト: KallynGowdy/TheFlow
 /// <summary>
 /// Sets the content of the body by creating a new edit by the given user.
 /// </summary>
 public void SetBody(string newBody, User editor)
 {
     if (newBody != null && editor != null)
     {
         Edits.Add(new TagEdit
         {
             Body = newBody,
             DateChanged = DateTime.UtcNow,
             Editor = editor,
             OriginalTag = this,
             PreviousVersion = Edits.OrderByDescending(a => a.DateChanged).FirstOrDefault()
         });
     }
 }
コード例 #6
0
ファイル: Post.cs プロジェクト: KallynGowdy/TheFlow
 /// <summary>
 /// Creates a new proposed edit using the given body and editor based off of the previous edit.
 /// </summary>
 /// <param name="proposedBody"></param>
 /// <param name="editor"></param>
 public void ProposeEdit(string proposedBody, User editor)
 {
     if (proposedBody != null && editor != null)
     {
         Edits.Add(new Edit
         {
             Accepted = false,
             Body = proposedBody,
             DateChanged = DateTime.UtcNow,
             Editor = editor,
             OriginalPost = this,
             PreviousVersion = Edits.OrderByDescending(a => a.DateChanged).FirstOrDefault()
         });
     }
 }
コード例 #7
0
ファイル: Question.cs プロジェクト: KallynGowdy/TheFlow
 public Question(User author, string body, string title, IList<Tag> tags)
     : base(author, body)
 {
     this.Title = title;
     this.Tags = tags;
 }
コード例 #8
0
ファイル: Question.cs プロジェクト: KallynGowdy/TheFlow
 public Question(User author, string body, string title, IEnumerable<Tag> tags)
     : base(author, body)
 {
     this.Title = title;
     this.Tags = tags.ToList();
 }