Example #1
0
        public async Task AddOrUpdateElasticNews(NewsUpdateOrCreateCommand newsUpdateOrCreate)
        {
            _routing.RouteToEndpoint(typeof(NewsUpdateOrCreateCommand), _messageQueueName);
            var endpointInstance = await Endpoint.Start(_endPoint).ConfigureAwait(false);

            await endpointInstance.Send(newsUpdateOrCreate).ConfigureAwait(false);

            await endpointInstance.Stop().ConfigureAwait(false);
        }
Example #2
0
        private async Task ToQueueElasticUpdate(News newNews)
        {
            NewsUpdateOrCreateCommand newsUpdateOrCreate = new NewsUpdateOrCreateCommand
            {
                ApplicationUserId = newNews.ApplicationUserId,
                Body         = newNews.Body,
                CategoryId   = newNews.CategoryId,
                CategoryName = (await _database.CategoryRepository.GetById(newNews.CategoryId)).Name,
                CreatedDate  = newNews.CreatedDate,
                Description  = newNews.Description,
                Id           = newNews.Id,
                Published    = newNews.Published,
                Title        = newNews.Title,
                UserName     = (await _database.ProfileRepository.GetById(newNews.ApplicationUserId)).Name
            };

            await _senderToElastic.AddOrUpdateElasticNews(newsUpdateOrCreate);
        }