public async Task <IActionResult> OnPost(int departmentId)
        {
            await _departmentData.DeleteDepartment(departmentId);

            TempData["Message"] = $"Department deleted";
            return(RedirectToPage("./List"));
        }
        public IActionResult DeleteDepartment(int id)
        {
            var department = _departmentData.GetDepartment(id);

            if (department != null)
            {
                _departmentData.DeleteDepartment(department);
                return(Ok());
            }
            return(NotFound($"Department with the id: {id} was not found"));
        }
Exemple #3
0
        private void btnDelete_Click(object sender, EventArgs e)
        {
            if (gridDepartments.SelectedRows.Count > 0)
            {
                //Confirm message before deleting
                int SelectedId         = int.Parse(gridDepartments.SelectedRows[0].Cells[0].Value.ToString());
                var selectedDepartment = _departments.First(d => d.Id == SelectedId);
                if (MessageBox.Show($"Are you sure you want to delete {selectedDepartment.DepartmentName} ?", "Confirm Delete", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
                {
                    return;
                }

                //Delete the selected department
                department.DeleteDepartment(selectedDepartment);
                Logger.WriteToFile(Logger.FullName, "successfully deleted a department");
                MessageBox.Show($"{selectedDepartment.DepartmentName} has been successfully deleted", "Delete", MessageBoxButtons.OK, MessageBoxIcon.Information);
                WireUp();
            }
        }
Exemple #4
0
 public IActionResult DeleteDepartment(int departmentId)
 {
     _DepartmentData.DeleteDepartment(departmentId);
     return(RedirectToAction("Index", "Department"));
 }