Esempio n. 1
0
        public override IEnumerable<WarningOccurrenceDto> Analyze(ISqlRepository sqlRepository, UrlDto urlDto)
        {
            var warningOccurrencesList = new List<WarningOccurrenceDto>();

            if (urlDto.Status != HttpStatusCode.OK)
            {
                return warningOccurrencesList;
            }

            foreach (var link in sqlRepository.GetWebPageLinks(urlDto.UrlId.Value))
            {
                if (link.Status == HttpStatusCode.NotFound)
                {
                    IWarning warning = GetWarning(typeof(BrokenLinkWarning));

                    warningOccurrencesList.Add(new WarningOccurrenceDto()
                    {
                        UrlId = (long)urlDto.UrlId,
                        Message = String.Format(warning.Description, link.Url),
                        WarningType = warning
                    }
                    );
                }
            }

            return warningOccurrencesList;
        }