private void EditGroup()
		{
			string message = string.Empty;
			var groupRecord = gridViewGroups.GetFocusedRow() as GroupModel;
			if (groupRecord != null)
			{
				using (var formEdit = new FormEditGroup(false,
														_groupTemplates.ToArray(),
														_groups.Where(x => !x.name.Equals(groupRecord.name)).Select(x => x.name).ToArray(),
														_users.Select(x => new UserModel
														{
															id = x.id,
															login = x.login,
															firstName = x.firstName,
															lastName = x.lastName,
															email = x.email,
															selected = (groupRecord.users != null && groupRecord.users.Any(y => y.id == x.id))
														}).ToArray(),
														_libraries.Select(x => new SoapLibrary
														{
															id = x.id,
															name = x.name,
															selected = (groupRecord.libraries != null && groupRecord.libraries.Any(y => y.id == x.id)),
															pages = x.pages.Select(y => new SoapLibraryPage
															{
																id = y.id,
																name = y.name,
																libraryId = y.libraryId,
																selected = (groupRecord.libraries != null && groupRecord.libraries.SelectMany(library => library.pages).Select(groupPage => groupPage.id).Contains(y.id))
															}).ToArray()
														}).ToArray()))
				{
					formEdit.comboBoxEditName.EditValue = groupRecord.name;
					if (formEdit.ShowDialog() == DialogResult.OK)
					{
						string id = groupRecord.id;
						string name = formEdit.comboBoxEditName.EditValue != null ? formEdit.comboBoxEditName.EditValue.ToString() : string.Empty;
						var users = new List<UserModel>(formEdit.AssignedUsers);
						var pages = new List<SoapLibraryPage>(formEdit.AssignedPages);
						using (var form = new FormProgress())
						{
							FormMain.Instance.ribbonControl.Enabled = false;
							Enabled = false;
							form.laProgress.Text = "Updating group...";
							form.TopMost = true;
							var thread = new Thread(() => WebSiteManager.Instance.SelectedSite.SetGroup(id, name, users.ToArray(), pages.ToArray(), out message));
							form.Show();
							thread.Start();
							while (thread.IsAlive)
							{
								Thread.Sleep(100);
								Application.DoEvents();
							}
							form.Close();
							Enabled = true;
							FormMain.Instance.ribbonControl.Enabled = true;
						}

						_userCollectionChanged = true;
						_groupsCollectionChanged = true;
						_libraraiesCollectionChanged = true;

						UpdateGroups(true, ref message);
					}
				}
				if (!string.IsNullOrEmpty(message))
					AppManager.Instance.ShowWarning(message);
			}
		}
		private void AddGroup()
		{
			string message = string.Empty;
			using (var formEdit = new FormEditGroup(true, _groupTemplates.ToArray(), _groups.Select(x => x.name).ToArray(), _users.Select(x => new UserModel { id = x.id, login = x.login, firstName = x.firstName, lastName = x.lastName, email = x.email }).ToArray(), _libraries.Select(x => new SoapLibrary { id = x.id, name = x.name, pages = x.pages.Select(y => new SoapLibraryPage { id = y.id, name = y.name, libraryId = y.libraryId }).ToArray() }).ToArray()))
			{
				if (formEdit.ShowDialog() == DialogResult.OK)
				{
					string id = Guid.NewGuid().ToString();
					string name = formEdit.comboBoxEditName.EditValue != null ? formEdit.comboBoxEditName.EditValue.ToString() : string.Empty;
					var users = new List<UserModel>(formEdit.AssignedUsers);
					var pages = new List<SoapLibraryPage>(formEdit.AssignedPages);
					using (var form = new FormProgress())
					{
						FormMain.Instance.ribbonControl.Enabled = false;
						Enabled = false;
						form.laProgress.Text = "Adding group...";
						form.TopMost = true;
						var thread = new Thread(() => WebSiteManager.Instance.SelectedSite.SetGroup(id, name, users.ToArray(), pages.ToArray(), out message));
						form.Show();
						thread.Start();
						while (thread.IsAlive)
						{
							Thread.Sleep(100);
							Application.DoEvents();
						}
						form.Close();
						Enabled = true;
						FormMain.Instance.ribbonControl.Enabled = true;
					}

					_userCollectionChanged = true;
					_groupsCollectionChanged = true;
					_libraraiesCollectionChanged = true;

					UpdateGroups(true, ref message);
				}
			}
			if (!string.IsNullOrEmpty(message))
				AppManager.Instance.ShowWarning(message);
		}