public async Task CreateEditTemplate(CTemplate templateContent) { templateContent.Content = HtmlCleaner.CleanHtml(templateContent.Content); var found = _templatesRepository.FirstOrDefault(a => a.Name == templateContent.Name); if (found == null) { await _templatesRepository.InsertOrUpdateAndGetIdAsync(new Template() { Content = templateContent.Content, Name = templateContent.Name, IsPartial = templateContent.IsPartial, }); } else { found.Content = templateContent.Content; await _templatesRepository.InsertOrUpdateAndGetIdAsync(found); } }
public IHttpActionResult LoadUrl(string url, string clientSecret) { var passkeySetting = ConfigurationManager.AppSettings["passkey"]; if (string.IsNullOrEmpty(url) || string.IsNullOrEmpty(clientSecret) || !clientSecret.Equals(passkeySetting)) { return(BadRequest()); } //GET HTML var web = new HtmlWeb(); var htmlDoc = web.Load(url); IHtmlCleaner htmlCleaner = new HtmlCleaner { HtmlSourceDoc = htmlDoc }; htmlDoc = htmlCleaner.CleanHtml(); IWordRankAnalyzer wordRankAnalyzer = new WordRankAnalyzer { HtmlSourceDoc = htmlDoc }; var wordsRankedList = wordRankAnalyzer.RankWords(); var totalWordCount = wordRankAnalyzer.TotalWordsInHtml; IImageAnalyzer imgAnalyzer = new ImageAnalyzer { WebSiteUrl = url, HtmlSourceDoc = htmlDoc }; var imgSourceList = imgAnalyzer.GetImageSources(); return(Ok(new { UrlRequested = url, TotalWordCount = totalWordCount, WordsRankedList = wordsRankedList, ImagesSources = imgSourceList })); }