public override Task OnDisconnected(bool stopCalled) { string ClientconnecetionID = Context.ConnectionId; using (var db = new SRServer.EntityFramework.MySignalRUsersEntities()) { var rToDel = db.UsersTemp.SingleOrDefault(x => x.UniqueUserID == ClientconnecetionID); if (rToDel != null) { db.UsersTemp.Remove(rToDel); db.SaveChanges(); } } return(base.OnDisconnected(stopCalled)); }
public override Task OnConnected() { //add to the database string ClientconnecetionID = Context.ConnectionId; Console.WriteLine("ConnectionId: " + ClientconnecetionID); using (var db = new SRServer.EntityFramework.MySignalRUsersEntities()) { SRServer.EntityFramework.UsersTemp usersTemp = new SRServer.EntityFramework.UsersTemp { UniqueUserID = ClientconnecetionID }; db.UsersTemp.Add(usersTemp); db.SaveChanges(); } return(base.OnConnected()); }