Пример #1
0
 public UserModel FindUserByConnectionId(BoardModel board, string userConnectionId)
 {
     foreach (var user in board.Users)
     {
         foreach (var connectionId in user.UserConnectionIds)
         {
             if (connectionId == userConnectionId)
             {
                 return(user);
             }
         }
     }
     return(null);
 }
Пример #2
0
        public BoardModel CreateBoard(string groupName)
        {
            BoardModel board = new BoardModel()
            {
                BoardId    = groupName,
                Name       = "",
                UniqueName = "",
                Pin        = _boardService.GenerateRoomPin(1000, 9999),
                Users      = new List <UserModel>(),
                ImageIds   = new List <string>()
            };

            return(board);
        }
Пример #3
0
        public UserModel CreateUser(string userId, string userConnectionId, BoardModel board, bool boardExisted)
        {
            UserModel user = new UserModel()
            {
                UserId            = userId,
                Username          = "******",
                Role              = boardExisted ? UserRole.Editor : UserRole.Creator,
                Boards            = new List <BoardModel>(),
                UserConnectionIds = new List <string>()
            };

            lock (_objectLock)
            {
                user.Boards.Add(board);
                user.UserConnectionIds.Add(userConnectionId);
            }
            return(user);
        }
Пример #4
0
        /// <summary>
        /// Přidá tabuly do listu
        /// </summary>
        /// <param name="board"></param>
        public void AddBoard(BoardModel board)
        {
            if (_boards.Count == 0)
            {
                board.UniqueName = "Board0";
            }
            else
            {
                int n = Int32.Parse(_boards[(_boards.Count - 1)].UniqueName.Split("Board")[1]);
                n++;
                board.UniqueName = "Board" + n.ToString();
            }

            lock (_objectLock)
            {
                _boards.Add(board);
            }
        }
Пример #5
0
 public UserModel FindUserById(BoardModel board, string userId)
 {
     return(board.Users.Find(x => x.UserId == userId));
 }
Пример #6
0
 /// <summary>
 /// Zjistí, zda-li na tabuli není žádný uživatel
 /// </summary>
 /// <param name="board"></param>
 /// <returns></returns>
 public bool isBoardEmpty(BoardModel board)
 {
     return(board.Users.All(user => user.UserConnectionIds.Count == 0));
 }