public int AddCrawlableUrl(Uri uri) { if (uri == null) { throw new ArgumentNullException("uri"); } if (string.IsNullOrWhiteSpace(uri.Host)) { throw new ArgumentNullException("uri.Host"); } var rawUrlId = GetOrCreateUrlIdFromUri(uri); var crawlableUrl = _unitOfWork .CrawlableUrlRepository .CrawlableUrls .SingleOrDefault(x => x.RawUrlId == rawUrlId); if (crawlableUrl != null) { return(crawlableUrl.Id); } crawlableUrl = new CrawlableUrlEntity() { IsActivated = true, RawUrlId = rawUrlId, Timestamp = DateTime.UtcNow }; _unitOfWork .CrawlableUrlRepository .Create(crawlableUrl); return(crawlableUrl.Id); }
public void Create(CrawlableUrlEntity crawlableUrlEntity) { if (crawlableUrlEntity == null) { throw new ArgumentNullException("crawlableUrlEntity"); } _context.CrawlableUrls.Add(crawlableUrlEntity); _context.SaveChanges(); }