private void teamEditMemberAdd_Click(object obj) { Mouse.OverrideCursor = Cursors.Wait; try { if (obj is AllUserAndTeam) { AllUserAndTeam newTeamMember = obj as AllUserAndTeam; newTeamMember.AddOrDelete = true; var teamMembers = this.teamEditMemberList.ItemsSource as ObservableCollection <AllUserAndTeam>; if (teamMembers.FirstOrDefault(x => x.Name.Equals(newTeamMember.Name)) == null) { teamMembers.Add(newTeamMember); } else { Mouse.OverrideCursor = null; DXMessageBox.Show("This user is already a member.", CVsVariables.SOTWARE_NAME, MessageBoxButton.OK, MessageBoxImage.Stop); } } } catch (Exception error) { Mouse.OverrideCursor = null; DXMessageBox.Show(error.Message, CVsVariables.SOTWARE_NAME, MessageBoxButton.OK, MessageBoxImage.Error); } finally { Mouse.OverrideCursor = null; } }
public bool DeleteMember(string teamName, AllUserAndTeam member) { try { using (Cafeteria_Vernier_dbEntities cvDatabase = new Cafeteria_Vernier_dbEntities()) { cvDatabase.TeamMembers.DeleteObject(cvDatabase.TeamMembers.First(x => x.UserID.Equals(member.Name) && x.Name.Equals(teamName))); cvDatabase.SaveChanges(); return(true); } } catch { throw new FaultException(ServiceVariables.ERROR_MESSAGES[0, 2]); } }