Пример #1
0
        public void Subscribe(string openId)
        {
            OpenIdsInfo openIdsInfo = context.OpenIdsInfo.FirstOrDefault((OpenIdsInfo p) => p.OpenId == openId);

            if (openIdsInfo != null)
            {
                if (!openIdsInfo.IsSubscribe)
                {
                    openIdsInfo.IsSubscribe = true;
                    context.Configuration.ValidateOnSaveEnabled = false;
                    context.SaveChanges();
                    context.Configuration.ValidateOnSaveEnabled = true;
                }
                return;
            }
            openIdsInfo = new OpenIdsInfo()
            {
                OpenId        = openId,
                SubscribeTime = DateTime.Now,
                IsSubscribe   = true
            };
            context.OpenIdsInfo.Add(openIdsInfo);
            context.Configuration.ValidateOnSaveEnabled = false;
            context.SaveChanges();
            context.Configuration.ValidateOnSaveEnabled = true;
        }
Пример #2
0
        public bool IsAttention(string openId)
        {
            OpenIdsInfo openIdsInfo = context.OpenIdsInfo.FirstOrDefault((OpenIdsInfo p) => p.OpenId == openId);

            if (openIdsInfo != null)
            {
                return(openIdsInfo.IsSubscribe);
            }
            return(IsAttentionByRPC(openId));
        }
Пример #3
0
        public void UnSubscribe(string openId)
        {
            OpenIdsInfo openIdsInfo = context.OpenIdsInfo.FirstOrDefault((OpenIdsInfo p) => p.OpenId == openId);

            if (openIdsInfo != null)
            {
                openIdsInfo.IsSubscribe = false;
                context.SaveChanges();
                return;
            }
            openIdsInfo = new OpenIdsInfo()
            {
                OpenId        = openId,
                SubscribeTime = DateTime.Now,
                IsSubscribe   = false
            };
            context.OpenIdsInfo.Add(openIdsInfo);
            context.SaveChanges();
        }