public string Convert(Database.Entities.Forum.UrlTip source, string destination, ResolutionContext context) { if (string.IsNullOrEmpty(source?.Href)) { return(null); } if (!NoClicksForTheseSites.Any(source.Href.Contains)) { return(source.Href); } var urlStart = source.Href.StartsWith("http:") ? "http:" : "https:"; return(source.Href.Replace($"{urlStart}//www.", "https://unv.is/")); }
private async Task ComplementPostWithPotentialUrlTipAndLineupAsync(int postId, Models.Forum.CRUD.Post post, List <Result> results) { if (!string.IsNullOrEmpty(post.UrlTipHref)) { if (!_dbClient.UrlTipEqualsCurrentUrlTipOnPostId(postId, post.UrlTipHref)) { if (!(post.UrlTipHref.StartsWith("http://") || post.UrlTipHref.StartsWith("https://"))) { post.UrlTipHref = post.UrlTipHref.Insert(0, "http://"); } var urlTip = new Database.Entities.Forum.UrlTip { PostId = postId, Clicks = 0, Href = post.UrlTipHref, Created = DateTime.Now }; results.Update(await _dbClient.CreateUrlTipAsync(urlTip), ResultMessages.CreateUrlTip); } } else { if (await _dbClient.PostHasAnUrlTipConnectedToItAsync(postId)) { await _dbClient.DeleteUrlTipAsync(postId); } } if (post.LineupId > 0) { var postToLineup = new Database.Entities.Forum.PostToLineup { PostId = postId, LineupId = post.LineupId, Created = DateTime.Now }; results.Update(await _dbClient.ConnectLineupToPostAsync(postToLineup), ResultMessages.CreateLineupToPost); } else { if (await _dbClient.PostHasALineupConnectedToItAsync(postId)) { await _dbClient.DeleteLineupConnectionToPostAsync(postId); } } }