Exemplo n.º 1
0
        public async Task <IEnumerable <ActiveOutageViewModel> > Handle(GetActiveOutagesQuery request, CancellationToken cancellationToken)
        {
            try
            {
                Logger.LogInformation("[OutageQueryHandler::GetActiveOutages] Sending a GET query to Outage service for active outages.");

                var outageAccessClient = OutageModelAccessClient.CreateClient();
                var activeOutages      = await outageAccessClient.GetAllActiveOutages();

                var activeOutageViewModels = _mapper.MapActiveOutages(activeOutages);
                return(activeOutageViewModels);
            }
            catch (Exception ex)
            {
                Logger.LogError("[OutageQueryHandler::GetActiveOutages] Failed to GET active outages from Outage service.", ex);
                throw ex;
            }
        }
Exemplo n.º 2
0
        public Task <IEnumerable <ActiveOutageViewModel> > Handle(GetActiveOutagesQuery request, CancellationToken cancellationToken)
        {
            return(Task.Run(() =>
            {
                using (OutageAccessProxy outageProxy = _proxyFactory.CreateProxy <OutageAccessProxy, IOutageAccessContract>(EndpointNames.OutageAccessEndpoint))
                {
                    try
                    {
                        _logger.LogInfo("[OutageQueryHandler::GetActiveOutages] Sending a GET query to Outage service for active outages.");
                        IEnumerable <ActiveOutageMessage> activeOutages = outageProxy.GetActiveOutages();

                        IEnumerable <ActiveOutageViewModel> activeOutageViewModels = _mapper.MapActiveOutages(activeOutages);
                        return activeOutageViewModels;
                    }
                    catch (Exception ex)
                    {
                        _logger.LogError("[OutageQueryHandler::GetActiveOutages] Failed to GET active outages from Outage service.", ex);
                        throw ex;
                    }
                }
            }));
        }