38 lines
761 B
C#
38 lines
761 B
C#
using System;
|
|
using System.Collections.Generic;
|
|
|
|
namespace HN.Domain
|
|
{
|
|
public sealed class Link
|
|
{
|
|
public Guid Id { get; }
|
|
public string Url { get; }
|
|
public DateTime CreatedAt { get; }
|
|
private List<Vote> _votes;
|
|
public IReadOnlyList<Vote> Votes { get { return _votes; } }
|
|
|
|
private Link(string url)
|
|
{
|
|
this.Id = Guid.NewGuid();
|
|
this.CreatedAt = DateTime.UtcNow;
|
|
this.Url = url;
|
|
this._votes = new List<Vote>();
|
|
}
|
|
|
|
public static Link FromUrl(string url)
|
|
{
|
|
return new Link(url);
|
|
}
|
|
|
|
public void Upvote()
|
|
{
|
|
_votes.Add(new Vote(VoteType.Up));
|
|
}
|
|
|
|
public void Downvote()
|
|
{
|
|
_votes.Add(new Vote(VoteType.Down));
|
|
}
|
|
}
|
|
}
|