private void DeleteButton_Click(object sender, EventArgs e) { EmployeeName selectedItem = listBox1.SelectedItem as EmployeeName; AccountData account = accountBL.GetByClientId(selectedItem.Id); accountBL.DeleteAccount(account.Id); bool valid = employeeBL.DeleteClient(selectedItem.Id); if (valid) { InitializeList(); UserActionData action = new UserActionData() { Description = "Deleted a user", Timestamp = DateTime.Now, UserId = this.user.Id }; userActionBL.InsertUserAction(action); } else { MessageBox.Show("Error", "Delete has been failed!", MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1 ); } }
// PUT: api/Unit/5 //public ServerResponse Put([FromBody]Account Account) //{ // var res = new ServerResponse(); // using (AccountBL AccountBL = new AccountBL()) // { // try // { // res.Data = AccountBL.UpdateAccount(Account); // } // catch (Exception ex) // { // res.Success = false; // } // } // return res; //} // DELETE: api/Unit/5 public ServerResponse Delete(string id) { var res = new ServerResponse(); using (AccountBL AccountBL = new AccountBL()) { try { res.Data = AccountBL.DeleteAccount(id); } catch (Exception ex) { res.Success = false; } } return(res); }