Пример #1
0
        public async Task <IActionResult> GetAdvertisementByIdAsync(int id)
        {
            _logger.LogInformation($"User trying to get advertisement with id {id}");
            var entity = await _advertisements.FindAdvertisementAsync(id);

            if (entity == default(Advertisement))
            {
                _logger.LogWarning($"User requested not existing advertisement by id {id}");
                return(NotFound());
            }

            //TODO: Sanitize entities for avoid OWASP Top 10 A7:2017-Cross-Site Scripting (XSS)
            _logger.LogInformation($"User received advertisement with id {id}");
            var result = _mapper.Map <AdvertisementDto>(entity);

            return(Ok(result));
        }