public bool EditWcsUser(WcsUser user, out string result) { if (!UserList.Exists(c => user.id == c.id)) { result = "不存在该用户信息!"; return(false); } if (UserList.Exists(c => user.id != c.id && user.username.Equals(c.username))) { result = "已经存在该用户名!"; return(false); } result = ""; WcsUser ouser = UserList.Find(c => c.id == user.id); ouser.name = user.name; ouser.username = user.username; ouser.password = user.password; ouser.exitwcs = user.exitwcs; ouser.memo = user.memo; ouser.role_id = user.role_id; return(PubMaster.Mod.RoleSql.EditeWcsUser(ouser)); }
private void FriendList_UserAdded(object sender, string e) { int newFriendIndex = friendList.Children.Add(new FriendItem() { Nickname = e }); ((FriendItem)friendList.Children[newFriendIndex]).MouseDown += ChatPage_MouseDown; if (UserList.Exists(e)) { ((FriendItem)friendList.Children[newFriendIndex]).IsOnline = true; } }
public bool AddWcsUser(WcsUser user, out string result) { if (UserList.Exists(c => user.username.Equals(c.username))) { result = "已经存在该用户名!"; return(false); } int id = UserList.Max(c => c.id); user.id = ++id; result = ""; UserList.Add(user); return(PubMaster.Mod.RoleSql.AddWcsUser(user)); }
public void EnsureInUserList() { if (string.IsNullOrEmpty(UserID) == false) { if (UserList.Exists(u => string.Compare(u.ID, this.UserID, true) == 0) == false) { OguUser user = (OguUser)OguUser.CreateWrapperObject(UserID, SchemaType.Users); if (string.IsNullOrEmpty(UserDisplayName) == false) { user.Name = UserDisplayName; user.DisplayName = UserDisplayName; } UserList.Add(user); } } }
public void Append(GameUser user) { lock (lockThis) { if (UserList.Count < MaxTeamNum) { if (!UserList.Exists(m => m.UserId.Equals(user.UserID))) { UserList.Add(new TeamUser { UserId = user.UserID, NickName = user.NickName, //UserLv = user.UserLv, //UseMagicID = user.UseMagicID }); } } } }
public bool IsUserMatch(string username, string password) { return(UserList.Exists(c => username.Equals(c.username) && password.Equals(c.password))); }
private void SaveNewUserButton_Click(object sender, RoutedEventArgs e) { try { if (LoginTextBox.Text == "" || PasswordTextBox.Password == "") { throw new Exception("Name and surname must be provided!"); } if (UserList.Exists(x => x.Username == LoginTextBox.Text)) { throw new Exception("User already exists!"); } if (AccessLevelChoiceComboBox.SelectedIndex == -1) { throw new Exception("You need to select access level!"); } UserAccess newUserAccess = UserAccess.Admin; var index = AccessLevelChoiceComboBox.SelectedIndex; if (index != -1) { switch (index) { case 0: newUserAccess = UserAccess.Admin; break; case 1: newUserAccess = UserAccess.Recepcjonista; break; case 2: newUserAccess = UserAccess.PracownikMedyczny; break; default: break; } using (var context = new DataBaseContext()) { if (newUserAccess == UserAccess.PracownikMedyczny) { if (FirstNameTextBox.Text == "" || LastNameTextBox.Text == "") { throw new Exception("Name and surname must be provided!"); } var NewMedicalWorker = new DbMedicalWorker() { FirstName = FirstNameTextBox.Text, LastName = LastNameTextBox.Text, Availabilities = new List <DbAvailability>(), Specializations = new List <DbSpecialization>(), Visits = new List <DbVisit>() }; context.MedicalWorkers.Add(NewMedicalWorker); context.SaveChanges(); context.Users.Add(new DbUser() { Login = LoginTextBox.Text, Password = PasswordTextBox.Password, UserAccess = newUserAccess, MedicalWorker = NewMedicalWorker }); context.SaveChanges(); } else { context.Users.Add(new DbUser() { Login = LoginTextBox.Text, Password = PasswordTextBox.Password, UserAccess = newUserAccess }); context.SaveChanges(); } } UserList = UserForUsersManagementTab.GetRepresentation(); } } catch (Exception ex) { MessageBox.Show(ex.Message); } }