Ejemplo n.º 1
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)
                });
            }
        }
Ejemplo n.º 2
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);
        }
Ejemplo n.º 3
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
                });
            }
        }
Ejemplo n.º 4
0
        private SingleEmailResult checkTheToEmailIsValid(SingleEmail singleEmail)
        {
            var emailResult = new SingleEmailResult();


            if (!IsValidEmail(singleEmail.To))
            {
                emailResult.To            = singleEmail.To;
                emailResult.Message       = ERROR_MESSAGE;
                emailResult.SubmittedAt   = DateTime.Now;
                emailResult.UniqueEmailID = singleEmail.UniqueEmailID;
                emailResult.ErrorCode     = OpResultCode.FAILURE;
                return(emailResult);
            }

            emailResult.To            = singleEmail.To;
            emailResult.Message       = OpResultCode.SUCCCESS.ToString();
            emailResult.SubmittedAt   = DateTime.Now;
            emailResult.UniqueEmailID = singleEmail.UniqueEmailID;
            emailResult.ErrorCode     = OpResultCode.SUCCCESS;

            return(emailResult);
        }
Ejemplo n.º 5
0
        private SingleEmailResult checkIfAlreadyUnsubcribed(SingleEmail singleEmail)
        {
            var emailResult = new SingleEmailResult();

            //user unsubscribed
            if (UnbsubscribedEmails.Contains(singleEmail.To))
            {
                emailResult.To            = singleEmail.To;
                emailResult.Message       = ERROR_MESSAGE;
                emailResult.SubmittedAt   = DateTime.Now;
                emailResult.UniqueEmailID = singleEmail.UniqueEmailID;
                emailResult.ErrorCode     = OpResultCode.FAILURE;
                return(emailResult);
            }

            emailResult.To            = singleEmail.To;
            emailResult.Message       = OpResultCode.SUCCCESS.ToString();
            emailResult.SubmittedAt   = DateTime.Now;
            emailResult.UniqueEmailID = singleEmail.UniqueEmailID;
            emailResult.ErrorCode     = OpResultCode.SUCCCESS;

            return(emailResult);
        }