Esempio n. 1
0
        public void AddedNewNews(string idNews)
        {
            if (string.IsNullOrEmpty(idNews))
            {
                return;
            }

            var queriesOneSubscriber = _subscribeRepository
                                       .GetAllSubscribers()
                                       .GroupBy(s => s.Email,
                                                s => s.Query,
                                                (email, queries) => new
            {
                Email   = email,
                Queries = queries
            });

            foreach (var subscriber in queriesOneSubscriber)
            {
                foreach (var query in subscriber.Queries)
                {
                    var result = _newsRepository.CheckExistNews(query, idNews);
                    if (!string.IsNullOrEmpty(result))
                    {
                        SendMessageAboutNewNews(subscriber.Email, result);
                        break;
                    }
                }
            }
        }