Пример #1
0
        private EmailResult ProcessBulkEmailResult(BulkEmailResult bulkEmailResult, ApplyBussinessRulesCmd request)
        {
            foreach (var singleEmailResult in bulkEmailResult.Results)
            {
                var email = singleEmailResult;
                ProcessSingleEmailResult(email, request);
            }

            return(bulkEmailResult);
        }
Пример #2
0
        private NotifyByEmailCmd GetSendEmailCmd(ApplyBussinessRulesCmd request, SingleEmailResult singleEmailResult)
        {
            switch (request.EmailRequest)
            {
            case SingleEmail singleEmail:
                return(new NotifyByEmailCmd
                {
                    EmailRequest = singleEmail
                });

            default:
                BulkEmail bulkEmail = request.EmailRequest as BulkEmail;
                return(new NotifyByEmailCmd
                {
                    EmailRequest = bulkEmail.Emails.Find(i => i.UniqueEmailID == singleEmailResult.UniqueEmailID)
                });
            }
        }
Пример #3
0
        private async Task <EmailResult> ProcessApplyBussinessRulesCmd(ApplyBussinessRulesCmd request)
        {
            var emailRequest = request.EmailRequest;
            var rulesResult  = _rulesEvaluator.RunAllRules(ref emailRequest);


            switch (rulesResult)
            {
            case SingleEmailResult singleEmailResult:
                return(ProcessSingleEmailResult(singleEmailResult, request));


            case BulkEmailResult bulkEmailResult:
                return(ProcessBulkEmailResult(bulkEmailResult, request));
            }

            return(rulesResult);
        }
Пример #4
0
        private object GetLogFailedEmailCmd(ApplyBussinessRulesCmd request, SingleEmailResult singleEmailResult)
        {
            switch (request.EmailRequest)
            {
            case SingleEmail singleEmail:
                return(new PersistentStorageActor.LogFailedEmailCmd
                {
                    EmailRequest = singleEmail,
                    FailureReason = singleEmailResult.Message
                });

            default:
                BulkEmail bulkEmail = request.EmailRequest as BulkEmail;
                return(new PersistentStorageActor.LogFailedEmailCmd
                {
                    EmailRequest = bulkEmail.Emails.Find(i => i.UniqueEmailID == singleEmailResult.UniqueEmailID),
                    FailureReason = singleEmailResult.Message
                });
            }
        }
Пример #5
0
        private SingleEmailResult ProcessSingleEmailResult(SingleEmailResult singleEmailResult, ApplyBussinessRulesCmd cmd)
        {
            singleEmailResult.MessageID = Guid.NewGuid().ToString();

            switch (singleEmailResult.ErrorCode)
            {
            case OpResultCode.SUCCCESS:
                var sendEmailCmd = GetSendEmailCmd(cmd, singleEmailResult);
                _emailSendingActor.Tell(sendEmailCmd);
                break;

            case OpResultCode.FAILURE:
                var logFailedEmailCmd = GetLogFailedEmailCmd(cmd, singleEmailResult);
                _failedEmailsActor.Tell(logFailedEmailCmd);
                break;
            }

            return(singleEmailResult);
        }