Example #1
0
        public async Task <VerifyWarrantyCaseResponse> Verify(
            VerifyWarrantyCaseRequest request)
        {
            var preCommitVerifyResult = await PreCommitVerify(request);

            if (!preCommitVerifyResult.IsSuccess)
            {
                var preCommitVerifyWarrantyCaseResponse = BuidVerifyWarrantyCaseResponse(
                    preCommitVerifyResult,
                    preSavedResponse: null);
                return(preCommitVerifyWarrantyCaseResponse);
            }
            var preSavedResponse = preCommitVerifyResult.Success; // null if not commit

            var requestId = RequestIdGenerator.GenerateRequestId();
            var operation = request.Operation;

            var performVerifyActionResult = await PerformVerifyAction(request, operation, requestId);

            var saveResult = await SaveWarrantyCaseResponse(request, operation, requestId, performVerifyActionResult);

            var successfulConditionResult = SatisfySuccessfulCondition(
                operation,
                isPreCommitVerify: false,
                saveResult);
            var verifyWarrantyCaseResponse = BuidVerifyWarrantyCaseResponse(
                successfulConditionResult,
                preSavedResponse: preSavedResponse);

            return(verifyWarrantyCaseResponse);
        }
Example #2
0
        // if the request is not Commit, returns Result with IsSuccess: true and Success: null
        internal async Task <Result <WarrantyCaseResponse, IFailure> > PreCommitVerify(
            VerifyWarrantyCaseRequest request)
        {
            if (request.Operation != WarrantyCaseOperation.Commit)
            {
                return(Result <WarrantyCaseResponse, IFailure> .SuccessNull());
            }

            var requestId = RequestIdGenerator.GenerateRequestId();

            var performVerifyActionResult = await PerformVerifyAction(request, WarrantyCaseOperation.Verify, requestId);

            var saveResult = await SaveWarrantyCaseResponse(request, WarrantyCaseOperation.Verify, requestId, performVerifyActionResult);

            var successfulConditionResult = SatisfySuccessfulCondition(
                WarrantyCaseOperation.Verify,
                isPreCommitVerify: true,
                saveResult);

            if (successfulConditionResult.IsSuccess)
            {
                return(successfulConditionResult);
            }
            else
            {
                var failure = successfulConditionResult.Failure !;
                return(new Result <WarrantyCaseResponse, IFailure>(
                           new VerifyBeforeCommitFailure(
                               message: $"Pre-commit verification failed RequestId: `{requestId}`, FailureType: `{failure.FailureType}`, FailureMessage: `{failure.Message}`.",
                               warrantyCaseResponse: failure is SuccessfulConditionFailure successfulConditionFailure
                            ? successfulConditionFailure.WarrantyCaseResponse
                            : null)));
            }
        }