public bool UpdateState(long SendUseId, long ReviceUserId, int state) { ChatRelationShip chatRelationShip = (from a in context.ChatRelationShip where a.ReviceUserId == ReviceUserId && a.SendUserId == SendUseId select a).FirstOrDefault <ChatRelationShip>(); if (chatRelationShip != null) { chatRelationShip.state = state; chatRelationShip.EndDateTime = DateTime.Now; context.SaveChanges(); } return(true); }
public void UpdateChatRelationShip(long SendUserId, long ReviceUserId) { ChatRelationShip chatRelationShip = (from a in context.ChatRelationShip where a.ReviceUserId == ReviceUserId && a.SendUserId == SendUserId select a).FirstOrDefault <ChatRelationShip>(); if (chatRelationShip == null) { chatRelationShip = new ChatRelationShip { SendUserId = SendUserId, ReviceUserId = ReviceUserId, state = 2, EndDateTime = DateTime.Now }; context.ChatRelationShip.Add(chatRelationShip); context.SaveChanges(); } else { chatRelationShip.state = 2; chatRelationShip.EndDateTime = DateTime.Now; context.SaveChanges(); } }