private async void btnSave_Click(object sender, EventArgs e) { if (this.ValidateChildren()) { var roles = clbRoles.CheckedItems.Cast <Model.Role>().Select(x => x.RoleId).ToList(); request.FirstName = txtFirstName.Text; request.LastName = txtLastName.Text; request.Email = txtEmail.Text; request.PhoneNumber = txtTelephone.Text; request.Password = txtPassword.Text; request.PasswordConfirmation = txtPasswordConfirmation.Text; request.Roles = roles; if (_id.HasValue) { await _userService.Update <Model.User>(_id, request); } else { await _userService.Insert <Model.User>(request); } MessageBox.Show("Uspjesno!"); this.Close(); var frm = new ucUsers(); var frmIndex = Application.OpenForms["frmIndex"]; var panelContainer = frmIndex.Controls.Find("panelMain", true).FirstOrDefault() as Panel; PanelHelper.AddPanel(panelContainer, frm); } }
private async void btnDelete_Click(object sender, EventArgs e) { var user = await _userService.Delete <Model.User>(_id); MessageBox.Show("Uspjesno obrisano!"); this.Close(); var frm = new ucUsers(); var frmIndex = Application.OpenForms["frmIndex"]; var panelContainer = frmIndex.Controls.Find("panelMain", true).FirstOrDefault() as Panel; PanelHelper.AddPanel(panelContainer, frm); }