public static List<User> RemoveUsers(this List<User> users, User user) { if (users.Where(s => s.UserName == user.UserName).Count()> 0) { var _user = users.Where(s => s.UserName == user.UserName).FirstOrDefault(); if (_user.ConnectionId.Count() > 2) _user.ConnectionId.RemoveConnection(user.ConnectionId.FirstOrDefault()); else users.Remove(_user); } return users; }
public static List<User> AddUsers(this List<User> users, User user) { if (users.Where(s => s.UserName == user.UserName).Count() == 0) { users.Add(user); return users; } else { var _user = users.Where(s => s.UserName == user.UserName).FirstOrDefault(); _user.ConnectionId.AddConnection(user.ConnectionId); return users; } }