Ejemplo n.º 1
0
        /// <summary>
        /// db context function to delete a tweet
        /// </summary>
        /// <param name="uid"></param>
        /// <param name="tid"></param>
        /// <returns></returns>
        public bool DeleteTweet(Guid uid, Guid tid)
        {
            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);
            }
        }
Ejemplo n.º 2
0
        public bool DeleteTag(Guid tweetId)
        {
            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);
            }
        }