Skip to content

Instantly share code, notes, and snippets.

@trikitrok
Last active December 6, 2025 21:31
Show Gist options
  • Select an option

  • Save trikitrok/3964c37c208e41d11d69fc0b0c82adee to your computer and use it in GitHub Desktop.

Select an option

Save trikitrok/3964c37c208e41d11d69fc0b0c82adee to your computer and use it in GitHub Desktop.
public class OpeningResult
{
private readonly string? _failureDescription;
private readonly ReferenceInCompany? _referenceInCompany;
private readonly ClaimId _claimId;
private OpeningResult(ReferenceInCompany? referenceInCompany, ClaimId claimId, string? failureDescription)
{
_failureDescription = failureDescription;
_claimId = claimId;
_referenceInCompany = referenceInCompany;
}
public static OpeningResult Success(ClaimId claimId, ReferenceInCompany referenceInCompany)
{
return new OpeningResult(refenceInCompany, claimId, null);
}
public static OpeningResult Failure(ClaimId claimId, string description)
{
return new OpeningResult(null, claimId, description);
}
public void Notify(ClaimCompanyId claimCompanyId, OpeningListener openingListener)
{
if (IsFailure())
{
openingListener.OpeningFailed(
new OpeningFailure(_failureDescription, _claimId, claimCompanyId)
);
}
else
{
openingListener.OpeningSucceeded(
new OpeningSuccess(_referenceInCompany, _claimId, claimCompanyId)
);
}
}
private bool IsFailure()
{
return _referenceInCompany == null;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment