int removeSuppressedEmail(int suppressedEmailID, int accountId)
        {
            string indexName = "suppressedemails" + accountId;
            var    client    = ElasticClient(indexName);
            int    count     = 0;

            if (client.IndexExists(i => i.Index(indexName)).Exists)
            {
                SuppressedEmail email        = null;
                var             documentById = client.Search <SuppressedEmail>(c => c.Query(q => q.Ids(new List <string>()
                {
                    suppressedEmailID.ToString()
                })));
                if (documentById != null && documentById.Documents.IsAny())
                {
                    email = documentById.Documents.FirstOrDefault();
                    IList <SuppressedEmail> emails = new List <SuppressedEmail>()
                    {
                        email
                    };
                    var    deleteResult = client.Bulk(b => b.DeleteMany(emails, (bid, c) => bid.Index(indexName)));
                    string dr           = deleteResult.ConnectionStatus.ToString();
                    count = deleteResult.Items.Count();
                }
            }
            Logger.Current.Informational("Total Removed suppressed emails:" + count);
            return(count);
        }
Example #2
0
        private IEnumerable <Suggestion> convertSuppressionList(IEnumerable <object> list, Type type)
        {
            List <Suggestion> results = new List <Suggestion>();

            if (list.IsAny())
            {
                foreach (var res in list)
                {
                    if (type.Equals(typeof(SuppressedEmail)))
                    {
                        SuppressedEmail email = res as SuppressedEmail;
                        results.Add(new Suggestion()
                        {
                            AccountId = email.AccountID, DocumentId = email.Id, Text = email.Email
                        });
                    }
                    else
                    {
                        SuppressedDomain domain = res as SuppressedDomain;
                        results.Add(new Suggestion()
                        {
                            AccountId = domain.AccountID, DocumentId = domain.Id, Text = domain.Domain
                        });
                    }
                }
            }
            return(results);
        }