示例#1
0
        public async Task HandleRequest(Link _ad)
        {
            _logger.LogDebug("Rozpoczynam logowanie zapytania");
            _logger.LogDebug("Url linku: {0}", _ad.ShortUrl);

            if (_ad == null)
            {
                throw new Exception("Given ad is null");
            }

            var        context    = _httpContextAccessor.HttpContext;
            string     uaString   = context.Request.Headers["User-Agent"].ToString();
            ClientInfo clientInfo = _uaParser.Parse(uaString);

            //build information about statistic
            UrlStatistic NewStatistic = UrlStatisticsBuilder.build(clientInfo, context);

            NewStatistic.Link = _ad;

            //check if has some statistics to this Ad
            if (_ad.UrlStatistics == null)
            {
                _ad.UrlStatistics = new List <UrlStatistic>();
            }

            _ad.UrlStatistics.Add(NewStatistic);
            await _urlStatisticsRepository.Add(NewStatistic);



            _logger.LogDebug("Zakończyłem logowanie zapytania");
        }
示例#2
0
        public async Task Add(UrlStatistic urlStatistic)
        {
            await _appDbContext.UrlStatistics.AddAsync(urlStatistic);

            await _appDbContext.SaveChangesAsync();
        }