public Task<SuccessResponse> Handle(DeleteDepartementCommand command, CancellationToken cancellationToken) { var result = new SuccessResponse(); var departement = _departementRepository.GetById(command.Id); if (departement == null) result.Reason = $"Departement with ID'{command.Id}' not found."; else { foreach (var employee in departement.Employees) _employeeRepository.Delete(employee); _departementRepository.Delete(departement); result.Success = true; } return Task.Run(() => result); }
public ActionResult Delete(int id) { departementRepository.Delete(id); return(RedirectToAction("Index", "Departement")); }