Last active
November 7, 2025 19:07
-
-
Save trikitrok/5a89081e54f868dddf18be4b75f2eb96 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 OpeningResult | |
| { | |
| private readonly OpenedClaimData _openedClaimData; | |
| private readonly string? _failureDescription; | |
| private readonly string? _referenceInCompany; | |
| private readonly string _claimId; | |
| private OpeningResult(string? refenceInCompany, string claimId, string? failureDescription) | |
| { | |
| _openedClaimData = new OpenedClaimData(refenceInCompany, claimId); | |
| _failureDescription = failureDescription; | |
| _claimId = claimId; | |
| _referenceInCompany = refenceInCompany; | |
| } | |
| public static OpeningResult Success(string refenceInCompany, string claimId) | |
| { | |
| return new OpeningResult(refenceInCompany, claimId, null); | |
| } | |
| public static OpeningResult Failure(string claimId, string? description) | |
| { | |
| return new OpeningResult(null, claimId, description); | |
| } | |
| public void Notify(string claimCompanyId, OpeningListener openingListener) | |
| { | |
| if (IsFailure()) | |
| { | |
| openingListener.OpeningFailed( | |
| new OpeningFailure(_failureDescription, _openedClaimData._claimId) | |
| ); | |
| } | |
| else | |
| { | |
| openingListener.OpeningSucceeded( | |
| new OpeningSuccess(_referenceInCompany, _claimId, claimCompanyId) | |
| ); | |
| } | |
| } | |
| private bool IsFailure() | |
| { | |
| return _referenceInCompany == null; | |
| } | |
| } | |
| ////////////////////////////////////////////// | |
| public abstract class OpeningResult | |
| { | |
| public static OpeningResult Success(string referenceInCompany, string claimId) | |
| { | |
| return new SuccessfulOpeningResult(claimId, referenceInCompany); | |
| } | |
| public static OpeningResult Failure(string claimId, string description) | |
| { | |
| return new FailingOpeningResult(claimId, description); | |
| } | |
| public abstract void Notify(string claimCompanyId, OpeningListener openingListener); | |
| private class SuccessfulOpeningResult(string claimId, string refenceInCompany) : OpeningResult | |
| { | |
| public override void Notify(string claimCompanyId, OpeningListener openingListener) | |
| { | |
| openingListener.OpeningSucceeded( | |
| new OpeningSuccess( | |
| refenceInCompany, | |
| claimId, | |
| claimCompanyId) | |
| ); | |
| } | |
| } | |
| private class FailingOpeningResult(string claimId, string failureDescription) : OpeningResult | |
| { | |
| public override void Notify(string claimCompanyId, OpeningListener openingListener) | |
| { | |
| openingListener.OpeningFailed( | |
| new OpeningFailure( | |
| failureDescription, claimId) | |
| ); | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment