This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Proposal : Aggregate | |
{ | |
public void Accept(IDomainService domainService) | |
{ | |
ChangeStatus(ProposalStatus.Accepted); | |
base.EventsRaised.Add(new ProposalAcceptedEvent(proposal.Id, proposal.AcceptedAt)) | |
domainService.DenyOtherCompaniesProposals(this); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var proposal = _proposalRepository.Find(id); | |
proposal.Candidate.Ban(); | |
proposal.JobListing.AddPreRequisite(PreRequisite.Clojure); | |
proposalRepository.Save(proposal); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var proposal = _proposalRepository.Find(id); | |
proposal.Candidate.Ban(); | |
proposalRepository.Save(proposal); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Proposal : Aggregate | |
{ | |
public Candidate CandidateId { get; } | |
public JobListing JobListingId { get; } | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var proposal = _proprosalRepository.Find(proposalId); | |
proposal.Discuss(candidateId, "I would like to know more about benefits"); | |
_proposalRepository.Save(proposal); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Proposal | |
{ | |
private List<Comments> _comments; | |
public ReadOnlyList<Comments> Comments => _comments.AsReadOnly(); | |
public void Discuss(Guid userId, string content) | |
{ | |
if(Status != ProposalStatus.Pending) | |
throw new DomainException("Can't discuss about an closed proposal"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Proposal | |
{ | |
public DateTime SentAt { get; set; } | |
public DateTime AcceptedAt { get; set; } | |
public ProposalStatus Status { get; set; } | |
public Guid CandidateId { get; set; } | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class ProposalService | |
{ | |
public void AcceptProposal(Guid proposalId) | |
{ | |
var proposal = _repository.Find(proposalId); | |
proposal.Accept(); | |
_repository.Save(proposal); | |
_domainService.DenyOtherCompaniesProposals(proposal); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class DomainService | |
{ | |
public class DenyOtherCompaniesProposals(Proposal proposal) | |
{ | |
var proposalsToDeny = _repository.FindOpenForCandidate(proposal.CandidateId); | |
foreach(var proposal in proposalsToDeny) | |
proposal.Deny(); | |
_repository.Save(proposalsToDeny); | |
} |