add exception filter when user not connected default to needing authentication and apply anonymous to some actions add user in get requests add user relation in link, comment and vote signup and in are ok now!
31 lines
653 B
C#
31 lines
653 B
C#
using System;
|
|
|
|
namespace HN.Domain
|
|
{
|
|
public sealed class Link : Votable
|
|
{
|
|
public Guid Id { get; }
|
|
public string Url { get; }
|
|
public DateTime CreatedAt { get; }
|
|
public Guid CreatedBy { get; }
|
|
|
|
private Link(Guid createdBy, string url) : base()
|
|
{
|
|
Id = Guid.NewGuid();
|
|
CreatedBy = createdBy;
|
|
CreatedAt = DateTime.UtcNow;
|
|
Url = url;
|
|
}
|
|
|
|
public static Link FromUrl(Guid posterId, string url)
|
|
{
|
|
return new Link(posterId, url);
|
|
}
|
|
|
|
public Comment AddComment(Guid userId, string content)
|
|
{
|
|
return new Comment(Id, userId, content);
|
|
}
|
|
}
|
|
}
|