private void RemoveUser(object sender, EventArgs e) { removeButton.Visible = true; int id = Convert.ToInt32(dataGridView1.SelectedCells[0].Value.ToString()); var user = repositoryUser.FindById(id); user.Groups.Clear(); repositoryUser.Update(user); repositoryUser.Remove(user); dataGridView1.DataSource = repositoryUser.GetAll().Select(x => new { Id = x.Id, Name = x.Name, Login = x.Login, Password = x.Password, isAdmin = x.isAdmin }).ToList(); }
private void RemoveGroup(object sender, EventArgs e) { removeButton.Visible = true; int id = Convert.ToInt32(dataGridView1.SelectedCells[0].Value.ToString()); var group = repositoryGroup.FindById(id); group.Tests.Clear(); group.Users.Clear(); repositoryGroup.Update(group); repositoryGroup.Remove(group); dataGridView1.DataSource = repositoryGroup.GetAll().Select(x => new { Id = x.Id, Tille = x.Title }).ToList(); }