public bool UnFollow(FollowDTO followdto) { Follow unfollow = DBContext.Follow.Where(ds => ds.Followed_UserID == followdto.UserToFollowID).FirstOrDefault(); DBContext.Follow.Remove(unfollow); DBContext.SaveChanges(); return(true); }
public bool AddTags(List <string> tags, Guid tweetid) { foreach (string s in tags) { Tag newtag = new Tag(); newtag.ID = Guid.NewGuid(); newtag.TweetID = tweetid; newtag.TagName = s; dbcontext.Tag.Add(newtag); dbcontext.SaveChanges(); } return(true); }
/// <summary> /// function to update search count of a particular tweet when it is being searched.. /// </summary> /// <param name="item"></param> /// <returns></returns> public bool updateSearchCount(Tag item) { Tag updateTag = DBContext.Tag.Where(dr => dr.ID == item.ID).FirstOrDefault(); if (updateTag.SearchCount == null) { updateTag.SearchCount = 1; } else { updateTag.SearchCount = updateTag.SearchCount + 1; } DBContext.SaveChanges(); return(true); }
public bool LikeTweet(LikeTweetDTO liketweetdto) { LikeTweet liketweet1 = DBContext.LikeTweet.Where(ds => ds.UserID == liketweetdto.LoggedInUserID && ds.TweetID == liketweetdto.TweetID).FirstOrDefault(); if (liketweet1 != null) { return(false); } else { LikeTweet liketweet = new LikeTweet(); liketweet.ID = System.Guid.NewGuid(); liketweet.TweetID = liketweetdto.TweetID; liketweet.UserID = liketweetdto.LoggedInUserID; DBContext.LikeTweet.Add(liketweet); DBContext.SaveChanges(); return(true); } }
public Guid UpdateTweet(NewTweetDTO updatedTweet) { using (glitterEntities DBContext = new glitterEntities()) { Tweet tweet = DBContext.Tweet.Where(ds => ds.ID == updatedTweet.TweetID).FirstOrDefault(); tweet.Message = updatedTweet.Message; tweet.CreatedAt = System.DateTime.Now; DBContext.SaveChanges(); } return(updatedTweet.TweetID); }
public bool DeleteTweet(Guid uid, Guid tid) { using (glitterEntities DBContext = new glitterEntities()) { Tweet tweet = DBContext.Tweet.Where(ds => ds.ID == tid && ds.UserID == uid).FirstOrDefault(); if (tweet != null) { tagdb.DeleteTag(tweet.ID); DBContext.Entry(tweet).State = EntityState.Deleted; DBContext.SaveChanges(); return(true); } else { return(false); } } }
/// <summary> /// Db Context dunction to delete all tags of a particular tweet /// </summary> /// <param name="tweetId"></param> /// <returns></returns> public bool DeleteTag(Guid tweetId) { using (glitterEntities DBContext = new glitterEntities()) { IList <Tag> taglist = DBContext.Tag.Where(dr => dr.TweetID == tweetId).ToList(); if (taglist.Count > 0) { foreach (var item in taglist) { DBContext.Entry(item).State = EntityState.Deleted; DBContext.SaveChanges(); } return(true); } else { return(false); } } }