public GetServiceProviderResponse GetAccountServiceProviders(GetServiceProviderRequest request)
        {
            GetServiceProviderResponse response = new GetServiceProviderResponse();

            Logger.Current.Verbose("Request to fetch communication logindetails for specific account.");
            IEnumerable <ServiceProvider> serviceProviders = serviceProviderRepository.GetAccountCommunicationProviders(request.AccountId, request.CommunicationTypeId, request.MailType);

            response.ServiceProviderViewModel = Mapper.Map <IEnumerable <ServiceProvider>, IEnumerable <ServiceProviderViewModel> >(serviceProviders);
            return(response);
        }
        private void SendUpdateEmail(int accountId, int neverBounceRequestId, int userId)
        {
            if (neverBounceRequestId != 0 & accountId != 0)
            {
                Guid    loginToken          = new Guid();
                string  accountPrimaryEmail = string.Empty;
                Email   senderEmail         = new Email();
                Account account             = accountService.GetAccountMinDetails(accountId);
                string  toEmail             = ConfigurationManager.AppSettings["NeverBounce_Update_Email"];
                if (account != null && !string.IsNullOrEmpty(toEmail))
                {
                    if (account.Email != null)
                    {
                        accountPrimaryEmail = account.Email.EmailId;
                    }

                    IEnumerable <ServiceProvider> serviceProviders = serviceProviderRepository.GetAccountCommunicationProviders(accountId, CommunicationType.Mail, MailType.TransactionalEmail);
                    if (serviceProviders != null && serviceProviders.FirstOrDefault() != null)
                    {
                        loginToken  = serviceProviders.FirstOrDefault().LoginToken;
                        senderEmail = serviceProviderRepository.GetServiceProviderEmail(serviceProviders.FirstOrDefault().Id);
                    }

                    var tomails = toEmail.Split(',');
                    foreach (string ToMail in tomails)
                    {
                        if (loginToken != new Guid() && accountPrimaryEmail != null)
                        {
                            string fromEmail = (senderEmail != null && !string.IsNullOrEmpty(senderEmail.EmailId)) ? senderEmail.EmailId : accountPrimaryEmail;

                            EmailAgent      agent       = new EmailAgent();
                            SendMailRequest mailRequest = new SendMailRequest();
                            mailRequest.Body          = GetBody(neverBounceRequestId, accountId, userId);
                            mailRequest.From          = fromEmail;
                            mailRequest.IsBodyHtml    = true;
                            mailRequest.ScheduledTime = DateTime.Now.ToUniversalTime().AddSeconds(5);
                            mailRequest.Subject       = string.Format("{0} - Email List Finished Validating", account.AccountName);
                            mailRequest.To            = new List <string>()
                            {
                                ToMail
                            };
                            mailRequest.TokenGuid     = loginToken;
                            mailRequest.RequestGuid   = Guid.NewGuid();
                            mailRequest.AccountDomain = account.DomainURL;
                            mailRequest.CategoryID    = (byte)EmailNotificationsCategory.MailTesterEmail;
                            mailRequest.AccountID     = accountId;
                            agent.SendEmail(mailRequest);
                        }
                    }
                }
            }
        }