예제 #1
0
        /// <summary>
        /// Gets result of correspondence by sent message
        /// </summary>
        /// <param name="messageId">Id of sent message</param>
        /// <returns>Result of correspondence by sent message</returns>
        private async Task <IEnumerable <RecipientCorrespondence> > GetCorrespondenceOfMessage(int messageId)
        {
            var result = new List <RecipientCorrespondence>();

            IEnumerable <Correspondence> correspondences = await _correspondenceRepository.GetAllByMessageId(messageId);

            foreach (Correspondence correspondence in correspondences)
            {
                Recipient recipient = await _recipientRepository.GetById(correspondence.RecipientId);

                if (recipient != null)
                {
                    var recipientCorrespondence = new RecipientCorrespondence
                    {
                        Email        = recipient.Email,
                        ErrorMessage = correspondence.ErrorMessage,
                        SendDate     = correspondence.SendDate
                    };

                    Enum.TryParse <Models.CorrespondenceResult>(correspondence.Result.ToString(),
                                                                out var correspondenceResult);
                    recipientCorrespondence.Result = correspondenceResult;

                    result.Add(recipientCorrespondence);
                }
            }

            return(result);
        }