コード例 #1
0
        public bool AddOrRemoveLike(LikeEntity like = null, int userId = 0)
        {
            if (userId > 0)
            {
                _ctx.Remove(like);
            }
            if (userId == 0)
            {
                _ctx.Add(like);
            }

            return(Save());
        }
コード例 #2
0
        public bool AddOrRemoveFlag(FlagEntity flag, int userId = 0)
        {
            if (userId == 0)
            {
                using (var context = new ContentContext())
                {
                    context.Add(flag);
                    return(context.SaveChanges() > 0);
                }
                // _ctx.Add(flag);
            }

            if (userId > 0)
            {
                using (var context = new ContentContext())
                {
                    context.Remove(flag);
                    return(context.SaveChanges() > 0);
                }
                // _ctx.Remove(flag);
            }
            return(Save());
        }
コード例 #3
0
        public bool AddOrRemoveVote(VoteEntity vote, int guestId = 0)
        {
            if (guestId > 0)
            {
                using (var context = new ContentContext())
                {
                    context.Remove(vote);
                    return(context.SaveChanges() > 0);
                }
                //_ctx.Remove<VoteEntity>(Upvote);
            }

            if (guestId == 0)
            {
                using (var context = new ContentContext())
                {
                    context.Add(vote);
                    return(context.SaveChanges() > 0);
                }
                //_ctx.Add<VoteEntity>(Upvote);
            }

            return(Save());
        }