Ejemplo n.º 1
0
        public async Task ShouldAddTwitterUser()
        {
            userId = await twitterUserService.Add(new TwitterUser { Username = "******", CredibilityScore = 69, });

            var result = (await twitterUserService.GetByFilter(x => x.Username == "TestUser")).FirstOrDefault();

            Assert.NotNull(result);
        }
Ejemplo n.º 2
0
 public async Task Post(TwitterUserViewModel model)
 {
     if (ModelState.IsValid)
     {
         await TwitterUserService.Add(model.ToEntity());
     }
 }
        protected async Task <NewsArticleCachedModel> ProcessUrl(string url)
        {
            HttpClient client = new HttpClient();

            ProcessedNewsArticle processedNewsArticle = null;
            var processingUrl            = _processingUnitUrl + "?tweet_url=" + url;
            HttpResponseMessage response = await client.GetAsync(processingUrl);

            if (response.IsSuccessStatusCode)
            {
                var responseStream = await response.Content.ReadAsStreamAsync();

                processedNewsArticle = await JsonSerializer.DeserializeAsync <ProcessedNewsArticle>(responseStream);
            }
            else
            {
                return(null);
            }

            var  user = (await TwitterUserService.GetAsQueriable()).Where(x => x.Username == processedNewsArticle.user).FirstOrDefault();
            Guid userId;

            if (user == null)
            {
                userId = await TwitterUserService.Add(processedNewsArticle.GetTwitterUser());
            }
            else
            {
                userId = user.Id;
                user   = processedNewsArticle.GetTwitterUser(user.Id);
                await TwitterUserService.Update(user);
            }

            var newsArticle = processedNewsArticle.GetAsModel();

            await Add(processedNewsArticle.GetNewsArticle(url, userId));

            return(newsArticle);
        }
Ejemplo n.º 4
0
 private async Task addTwitterUser()
 {
     userId = await twitterUserService.Add(new TwitterUser { Username = "******", CredibilityScore = 69, });
 }