hn-dotnet/Domain/Comment.cs

34 lines
743 B
C#

using System;
using System.Collections.Generic;
namespace HN.Domain
{
public sealed class Comment
{
public Guid Id { get; private set; }
public Guid LinkId { get; private set; }
public string Content { get; private set; }
public DateTime CreatedAt { get; private set; }
private List<Vote> _votes;
public IReadOnlyList<Vote> Votes => _votes;
internal Comment(Guid linkId, string content)
{
Id = Guid.NewGuid();
LinkId = linkId;
Content = content;
CreatedAt = DateTime.UtcNow;
_votes = new List<Vote>();
}
public void Upvote()
{
_votes.Add(new Vote(VoteType.Up));
}
public void Downvote()
{
_votes.Add(new Vote(VoteType.Down));
}
}
}