public IActionResult Delete(Guid id)
 {
     if (EmployeeHelper.DeleteEmployee(_memoryCache, id))
     {
         return(Ok());
     }
     else
     {
         return(BadRequest(new { Error = "Could not delete employee." }));
     }
 }
Esempio n. 2
0
        private void btnDeleteEmployee_Click(object sender, EventArgs e)
        {
            if (dataGridEmployee.SelectedRows.Count == 1)
            {
                // var Cells =  dataGridEmployee.SelectedRows[0].Cells;
                //   foreach(DataGridViewCell cell in Cells )
                //   {listOfEmployees[dataGridEmployee.SelectedRows[0].Index]
                //       dataGridEmployee.SelectedRows[0].i
                //   }
                var employee = listOfEmployees[dataGridEmployee.SelectedRows[0].Index];
                if (employee == null)
                {
                    return;
                }

                var dialogResult = MessageBox.Show("Potwierdź usunięcie pracownika: " + Environment.NewLine + Environment.NewLine + employee.Name + " " + employee.Surname + Environment.NewLine + "Zmiany te sa NIEODWRACALNE", "Usuwanie pracownika z bazy danych", MessageBoxButtons.OKCancel, MessageBoxIcon.Exclamation);

                if (dialogResult == DialogResult.OK)
                {
                    EmployeeHelper.DeleteEmployee(employee);
                }
                RefreshTable();
            }
        }