public void EditUser()
		{
			string message = string.Empty;
			var userRecord = gridViewUsers.GetFocusedRow() as UserModel;
			if (userRecord == null) return;
			using (var formEdit = new FormEditUser(false, _complexPassword, _users.Select(x => x.login).ToArray(),
												   _groups.Select(x => new GroupModel
												   {
													   id = x.id,
													   name = x.name,
													   selected = (userRecord.groups != null && userRecord.groups.Any(y => y.id == x.id))
												   }).ToArray(),
												   _libraries.Select(x => new SoapLibrary
												   {
													   id = x.id,
													   name = x.name,
													   selected = (userRecord.libraries != null && userRecord.libraries.Any(y => y.id == x.id)),
													   pages = x.pages.Select(y => new SoapLibraryPage
													   {
														   id = y.id,
														   name = y.name,
														   libraryId = y.libraryId,
														   selected = (userRecord.libraries != null && userRecord.libraries.Where(library => library.pages != null).SelectMany(library => library.pages).Select(userPage => userPage.id).Contains(y.id))
													   }).ToArray()
												   }).ToArray()))
			{
				formEdit.textEditLogin.EditValue = userRecord.login;
				formEdit.textEditFirstName.EditValue = userRecord.firstName;
				formEdit.textEditLastName.EditValue = userRecord.lastName;
				formEdit.textEditPhone.EditValue = userRecord.phone;
				formEdit.textEditEmail.EditValue = userRecord.email;
				formEdit.textEditEmailConfirm.EditValue = userRecord.email;
				if (formEdit.ShowDialog() == DialogResult.OK)
				{
					string login = formEdit.textEditLogin.EditValue != null ? formEdit.textEditLogin.EditValue.ToString() : string.Empty;
					string password = formEdit.buttonEditPassword.EditValue != null ? formEdit.buttonEditPassword.EditValue.ToString() : string.Empty;
					string firstName = formEdit.textEditFirstName.EditValue != null ? formEdit.textEditFirstName.EditValue.ToString() : string.Empty;
					string lastName = formEdit.textEditLastName.EditValue != null ? formEdit.textEditLastName.EditValue.ToString() : string.Empty;
					string email = formEdit.textEditEmail.EditValue != null ? formEdit.textEditEmail.EditValue.ToString() : string.Empty;
					string phone = formEdit.textEditPhone.EditValue != null ? formEdit.textEditPhone.EditValue.ToString() : string.Empty;
					var role = 0;
					var groups = new List<GroupModel>(formEdit.AssignedGroups);
					var pages = new List<SoapLibraryPage>(formEdit.AssignedPages);
					using (var form = new FormProgress())
					{
						FormMain.Instance.ribbonControl.Enabled = false;
						Enabled = false;
						form.laProgress.Text = "Updating user...";
						form.TopMost = true;
						var thread = new Thread(() => WebSiteManager.Instance.SelectedSite.SetUser(login, password, firstName, lastName, email, phone, role, groups.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;

					UpdateUsers(true, ref message);
				}
			}
			if (!string.IsNullOrEmpty(message))
				AppManager.Instance.ShowWarning(message);
		}
		public void AddUser()
		{
			string message = string.Empty;
			using (var formEdit = new FormEditUser(true, _complexPassword, _users.Select(x => x.login).ToArray(), _groups.Select(x => new GroupModel { id = x.id, name = x.name }).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 login = formEdit.textEditLogin.EditValue != null ? formEdit.textEditLogin.EditValue.ToString() : string.Empty;
					string password = formEdit.buttonEditPassword.EditValue != null ? formEdit.buttonEditPassword.EditValue.ToString() : string.Empty;
					string firstName = formEdit.textEditFirstName.EditValue != null ? formEdit.textEditFirstName.EditValue.ToString() : string.Empty;
					string lastName = formEdit.textEditLastName.EditValue != null ? formEdit.textEditLastName.EditValue.ToString() : string.Empty;
					string email = formEdit.textEditEmail.EditValue != null ? formEdit.textEditEmail.EditValue.ToString() : string.Empty;
					string phone = formEdit.textEditPhone.EditValue != null ? formEdit.textEditPhone.EditValue.ToString() : string.Empty;
					int role = 0;
					var groups = new List<GroupModel>(formEdit.AssignedGroups);
					var pages = new List<SoapLibraryPage>(formEdit.AssignedPages);
					using (var form = new FormProgress())
					{
						FormMain.Instance.ribbonControl.Enabled = false;
						Enabled = false;
						form.laProgress.Text = "Adding user...";
						form.TopMost = true;
						var thread = new Thread(() => WebSiteManager.Instance.SelectedSite.SetUser(login, password, firstName, lastName, email, phone, role, groups.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;

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