public override IEnumerable<WarningOccurrenceDto> Analyze(ISqlRepository sqlRepository, UrlDto urlDto) { var warningOccurrencesList = new List<WarningOccurrenceDto>(); if (urlDto.Contents == null) { _log.Debug("urlDto is empty for url:" + urlDto.Url); return warningOccurrencesList; } if (urlDto.Status != HttpStatusCode.OK) { return warningOccurrencesList; } var title = urlDto.Contents.SingleOrDefault(element => element.ContentType == ContentTypesEnum.Title); _log.Debug(String.Format("Analyze title '{0}' for url '{1}'", (title == null || title.Element == null) ? "" : title.Element, urlDto.Url)); if (title == null || String.IsNullOrEmpty(title.Element)) { IWarning warning = GetWarning(typeof(EmptyTitleWarning)); warningOccurrencesList.Add(new WarningOccurrenceDto() { UrlId = (long) urlDto.UrlId, Message = warning.Description, WarningType = warning } ); } else { var elements = sqlRepository.GetContentForElementText(ContentTypesEnum.Title, title.Element); if (elements.Any()) { ContentDto targetContentDto = elements.FirstOrDefault(x => x.UrlId != urlDto.UrlId); if (targetContentDto != null) { UrlDto targetUrlDto; sqlRepository.FindUrl(targetContentDto.UrlId, out targetUrlDto); IWarning warning = GetWarning(typeof(DuplicatedTitleWarning)); warningOccurrencesList.Add(new WarningOccurrenceDto() { UrlId = (long)urlDto.UrlId, Message = String.Format(warning.Description, title.Element, targetUrlDto.Url), WarningType = warning } ); } } } return warningOccurrencesList; }