private void AddNew_Click(object sender, EventArgs e)
 {
     try
     {
         using (var newUserForm = new AddNewUserForm())
         {
             if (newUserForm.ShowDialog() == DialogResult.OK)
             {
                 using (UserService userService = new UserService())
                 {
                     var user = userService.CreateNew(newUserForm.NewUser);
                     UsersList.Items.Add(new ListViewItem(new[]
                     {
                         user.Id.ToString(),
                         user.Name,
                         user.PasswordHash
                     }));
                 }
             }
         }
     }
     catch (Exception ex)
     {
         ex.DisplayMessage();
     }
 }
 private void DeleteSelected_Click(object sender, EventArgs e)
 {
     try
     {
         List<long> keysToDelete = new List<long>();
         foreach (ListViewItem row in UsersList.Items)
         {
             var idString = row.SubItems[0].Text;
             long id;
             if (long.TryParse(idString, out id))
             {
                 keysToDelete.Add(id);
             }
         }
         using (UserService userService = new UserService())
         {
             userService.DeleteAll(keysToDelete);
         }
         RefreshData();
     }
     catch (Exception ex)
     {
         ex.DisplayMessage();
     }
 }
 private void RefreshData()
 {
     using (UserService userService = new UserService())
     {
         var users = userService.GetAll();
         UsersList.Items.Clear();
         UsersList.Items.AddRange(users.Select(u => new ListViewItem(new[]
         {
             u.Id.ToString(),
             u.Name,
             u.PasswordHash
         })).ToArray());
     }
 }