Esempio n. 1
0
        public async Task <Result> Create(CreateNationalSocietyRequestDto dto)
        {
            if (_nyssContext.NationalSocieties.Any(ns => ns.Name.ToLower() == dto.Name.ToLower()))
            {
                return(Error <int>(ResultKey.NationalSociety.Creation.NameAlreadyExists));
            }

            var nationalSociety = new NationalSociety
            {
                Name            = dto.Name,
                ContentLanguage = await GetLanguageById(dto.ContentLanguageId),
                Country         = await GetCountryById(dto.CountryId),
                IsArchived      = false,
                StartDate       = DateTime.UtcNow
            };

            if (nationalSociety.ContentLanguage == null)
            {
                return(Error <int>(ResultKey.NationalSociety.Creation.LanguageNotFound));
            }

            if (nationalSociety.Country == null)
            {
                return(Error <int>(ResultKey.NationalSociety.Creation.CountryNotFound));
            }

            await _nyssContext.AddAsync(nationalSociety);

            await _nyssContext.SaveChangesAsync();

            _loggerAdapter.Info($"A national society {nationalSociety} was created");
            return(Success(nationalSociety.Id));
        }
Esempio n. 2
0
        static void Main(string[] args)
        {
            ConfigureDI();

            var path = _serviceProvider.GetRequiredService <IPathAbstraction>();

            var tempFileName = path.GetTempFileName();

            _logger.Info("All Done!");
        }
Esempio n. 3
0
        private void HandleConnectionError()
        {
            // TODO: [TESTS] (RabbitConnection.HandleConnectionError) Add tests
            _connectionErrorCount += 1;

            // Enter cooldown if we hit the configured threshold
            if (_connectionErrorCount >= _config.CoolDownThreshold)
            {
                HandleCoolDown();
                return;
            }

            // Temporarily disable the connection for a few seconds
            _disabledUntil = _dateTime.Now.AddSeconds(_config.BackOffTimeSec);

            _logger.Info(
                "Backing off Rabbit connection for {s} second(s), will try again at {d}",
                _config.BackOffTimeSec,
                _disabledUntil
                );
        }
Esempio n. 4
0
        // Internal methods
        private DevHttpResponse GetResponse(HttpRequestMessage requestMessage)
        {
            // TODO: [TESTS] (DevGrafanaHttpClient.GetResponse) Add tests
            var url = requestMessage.RequestUri.OriginalString;

            // Find exact matches
            var match = _responses.FirstOrDefault(x => x.ExactUrlMatch(url));

            if (match != null)
            {
                _logger.Info("Found matching response ({url}) {type}",
                             url, match.ResponseType.ToString("G")
                             );

                return(match);
            }

            // Unable to find a matching response
            _logger.Warning("Unable to find matching response for: {url}", url);
            return(null);
        }
Esempio n. 5
0
 public void Info(string message)
 {
     Logger.Info(message);
 }
Esempio n. 6
0
        public Task WriteAsync(CancellationToken cancellation)
        {
            _logger.Info("Monitor triggered!");

            return(Task.CompletedTask);
        }