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; }
public bool IsAttention(string openId) { OpenIdsInfo openIdsInfo = context.OpenIdsInfo.FirstOrDefault((OpenIdsInfo p) => p.OpenId == openId); if (openIdsInfo != null) { return(openIdsInfo.IsSubscribe); } return(IsAttentionByRPC(openId)); }
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(); }