コード例 #1
0
 public void AddTagTweetMapping(HashTagTweetMapDTO hashTagTweetMapDTO)
 {
     try
     {
         HashTagTweetMap hashTagTweetMap = new HashTagTweetMap();
         hashTagTweetMap.TweetId   = hashTagTweetMapDTO.TweetId;
         hashTagTweetMap.HashTagId = hashTagTweetMapDTO.HashTagId;
         db.HashTagTweetMaps.Add(hashTagTweetMap);
         Save();
     }
     catch (Exception) {
         Console.WriteLine("Exception in database handling.");
     }
 }
コード例 #2
0
 public void DeleteTagTweetMapping(HashTagTweetMapDTO hashTagTweetMapDTO)
 {
     try {
         //get the hashTagMapping object from the database
         var hashTagTweetMapObj = db.HashTagTweetMaps
                                  .Where(x => x.TweetId == hashTagTweetMapDTO.TweetId && x.HashTagId == hashTagTweetMapDTO.HashTagId).FirstOrDefault();
         if (hashTagTweetMapObj != null)
         {
             db.HashTagTweetMaps.Remove(hashTagTweetMapObj);
             Save();
         }
     }
     catch (Exception) {
         Console.WriteLine("Error in database connectivity");
     }
 }
コード例 #3
0
        // used to delete a particular tweet from the databse
        public TweetDTO DeleteTweet(TweetDTO tweetDTO)
        {
            TweetDTO tweet = objDb.GetByID(tweetDTO.TweetId);
            //get all the hashtags contain in that tweet
            IList <string> hashTags = GetHashTags(tweet.TweetContent);

            //for each hashtag update the mapping Table  first and then update the hashtag table
            foreach (string hashTag in hashTags)
            {
                int hashTagId = objHashTagDb.GetHashTagId(hashTag);
                // update the hasshTagTweetMapping Table based on the hashtagId and the tweetId
                HashTagTweetMapDTO hashTagTweetMapDTO = new HashTagTweetMapDTO();
                hashTagTweetMapDTO.TweetId   = tweetDTO.TweetId;
                hashTagTweetMapDTO.HashTagId = hashTagId;
                objTagTweetMappingDb.DeleteTagTweetMapping(hashTagTweetMapDTO);
                objHashTagDb.UpdateHashTag(hashTag);
            }
            objDb.Delete(tweet.TweetId);
            return(tweet);
        }
コード例 #4
0
        //Adding Tweet
        public TweetDTO AddTweet(TweetDTO tweetDTO)

        {
            TweetDTO       outTweetDTo = objDb.AddTweet(tweetDTO);
            IList <string> hashTags    = GetHashTags(tweetDTO.TweetContent);


            foreach (string hashTag in hashTags)
            {
                int hashTagId = objDb.AddHashTag(hashTag);

                HashTagTweetMapDTO hashTagTweetMapDTO = new HashTagTweetMapDTO();

                hashTagTweetMapDTO.TweetId   = outTweetDTo.TweetId;
                hashTagTweetMapDTO.HashTagId = hashTagId;

                AddTagTweetMapping(hashTagTweetMapDTO);
            }

            return(outTweetDTo);
        }
コード例 #5
0
 public void AddTagTweetMapping(HashTagTweetMapDTO hashTagTweetMapDTO)
 {
     objDb.AddTagTweetMapping(hashTagTweetMapDTO);
 }