private UserState InitializeUserState(string userName) { var initializedUserState = new UserState(userName); initializedUserState.SetId(Guid.NewGuid()); userRepository.Add(new User { Id = initializedUserState.Id, Name = initializedUserState.Name }); return(initializedUserState); }
private UserState GetUserState(string userName) { var user = userRepository.GetByName(userName); if (user == null) { return(null); } var stateFromDb = new UserState(userName); stateFromDb.SetId(user.Id); if (user.LastRoomId.HasValue) { var room = roomRepository.GetById(user.LastRoomId.Value); stateFromDb.SetLastRoom(room); } return(stateFromDb); }