Beispiel #1
0
        public SendEmailState SendEmailDeserialize(IReceivedData receivedData)
        {
            var state = new SendEmailState
            {
                ReceivedData = receivedData
            };

            try
            {
                state.SendEmail = state.ReceivedData.ContentType switch
                {
                    Constants.HeaderValueForLetter =>
                    _serializationProvider
                    .Deserialize <SendEmail>(state.ReceivedData.Letter.Body),

                    _ => _serializationProvider
                    .Deserialize <SendEmail>(state.ReceivedData.Data)
                };

                state.StepSuccess[SendEmailDeserializeStepKey] = state.SendEmail != default || state.SendEmail != null;
            }
            catch (Exception ex)
            {
                _logger.LogError(ex, SendEmailDeserializeError);
                state.StepSuccess[SendEmailDeserializeStepKey] = false;
            }

            return(state);
        }
Beispiel #2
0
        public async Task <SendEmailState> SendEmailAsync(SendEmailState state)
        {
            if (state.StepSuccess[SendEmailDeserializeStepKey])
            {
                try
                {
                    await _emailService.SendAsync(
                        state.SendEmail.EmailAddress,
                        state.SendEmail.EmailSubject,
                        state.SendEmail.EmailBody,
                        state.SendEmail.IsHtml,
                        new SenderInfo()).ConfigureAwait(false);

                    state.StepSuccess[SendEmailStepKey] = true;
                }
                catch (Exception ex)
                {
                    _logger.LogError(ex, SendEmailDeserializeError);
                    state.StepSuccess[SendEmailError] = false;
                }
            }

            return(state);
        }