Skip to content

Instantly share code, notes, and snippets.

@MarcoNicolodi
Last active November 29, 2019 13:43
Show Gist options
  • Save MarcoNicolodi/8a827ea32b42adfb09de8d9ceda789c8 to your computer and use it in GitHub Desktop.
Save MarcoNicolodi/8a827ea32b42adfb09de8d9ceda789c8 to your computer and use it in GitHub Desktop.
Proposal before being
public class Proposal : Entity
{
public Guid CandidateId { get; }
public Guid JobListingId { get; }
public ProposaStatus Status { get; private set; }
public DateTime? ClosedAt { get; private set; }
public Proposal(Guid candidateId, Guid jobListingId)
{
CandidateId = candidateId;
JobListingId = jobListingId;
Status = ProprosalStatus.Open;
}
public void Accept()
{
ChangeStatus(ProposalStatus.Accepted);
base.EventsRaised.Add(new ProposalAcceptedEvent(proposal.Id, proposal.AcceptedAt))
}
public void Deny()
{
ChangeStatus(ProposalStatus.Denied);
base.EventsRaised.Add(new ProposalDeniedEvent(proposal.Id, proposal.AcceptedAt))
}
private void ChangeStatus(ProposalStatus newStatus)
{
if(DateTime.Now.Substract(proprosal.SentAt).TotalDays > 15)
throw new DomainException("This proprosal has expired");
if(Status != ProposalStatus.Pending)
throw new DomainException("Cannot accept or deny this proposal");
Status = newStatus;
ClosedAt = DateTime.Now;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment