public UserItemData GetOrAddUserData(string userId) { if (UserDataList == null) { UserDataList = new List <UserItemData>(); } UserItemData userData = null; foreach (var i in UserDataList) { if (string.Equals(userId, i.UserId.ToString("N", CultureInfo.InvariantCulture), StringComparison.OrdinalIgnoreCase)) { userData = i; } } if (userData == null) { userData = new UserItemData() { UserId = new Guid(userId) }; UserDataList.Add(userData); } return(userData); }
public void UpdateUser(UserData data) { UserData user; if (UserDataList.ContainsKey(data.Id)) { user = UserDataList[data.Id]; } else { user = new UserData(data.Id); user.Name = data.Name; user.ThumbnailURL = data.ThumbnailURL; OnInitializeUser?.Invoke(user); UserDataList.Add(data.Id, user); } if (user.Location == data.Location) { // インスタンス移動なし // サムネイル変更 if (user.ThumbnailURL != data.ThumbnailURL) { user.ThumbnailURL = data.ThumbnailURL; OnUpdateUser?.Invoke(user); } } else { if (!String.IsNullOrWhiteSpace(user.Location) && LocationDataList.ContainsKey(user.Location)) { var oldLocation = LocationDataList[user.Location]; oldLocation.Users.Remove(user); if (oldLocation.Users.Count == 0) { LocationDataList.Remove(oldLocation.Id); OnLostLocation?.Invoke(oldLocation); } OnRemoveUser?.Invoke(oldLocation, user); } user.Location = data.Location; LocationData newLocation; if (LocationDataList.ContainsKey(data.Location)) { newLocation = LocationDataList[data.Location]; } else { newLocation = new LocationData(data.Location); LocationDataList.Add(data.Location, newLocation); OnInitializeLocation?.Invoke(newLocation); } newLocation.Users.Add(user); OnAddUser?.Invoke(newLocation, user); } }
private void Login() { UserModel user = new UserModel(); user.UserID = _UserID; user.UserPW = _UserPW; UserDataList.Add(user); // 아이디, 패스워드 일치 확인 _UserID = ""; _UserPW = ""; OnPropertyChanged("UserID"); OnPropertyChanged("UserPW"); }
public UserItemData GetOrAddUserData(string userId) { if (UserDataList == null) { UserDataList = new List <UserItemData>(); } var userData = UserDataList.FirstOrDefault(i => string.Equals(userId, i.UserId.ToString("N"), StringComparison.OrdinalIgnoreCase)); if (userData == null) { userData = new UserItemData() { UserId = new Guid(userId) }; UserDataList.Add(userData); } return(userData); }