public async Task <JsonResponse> DeleteMenu(int id) { var module = await _permissionServices.QueryById(id); if (module == null) { throw new UserOperationException("菜单不存在"); } var puResult = await _permissionServices.DeleteByIdAsync(id); if (puResult <= 0) { throw new UserOperationException("删除失败"); } return(new JsonResponse(true)); }
public async Task <JsonResponse> DeleteOperation(int id) { var operation = await _operationServices.QueryById(id); if (operation == null) { throw new UserOperationException("该功能不存在"); } _unitOfWork.Begin(); var delOperaResult = await _operationServices.DeleteByIdAsync(id); var permisOperation = (await _permissionOperationServices.Query(po => po.OperationId == operation.Id)).SingleOrDefault(); if (permisOperation != null) { if ((await _permissionOperationServices.DeleteByIdAsync(permisOperation.Id)) <= 0) { _unitOfWork.Rollback(); throw new UserOperationException("删除失败"); } var permission = (await _permissionServices.Query(p => p.Id == permisOperation.PermissionId)).SingleOrDefault(); if (permission != null) { if ((await _permissionServices.DeleteByIdAsync(permission.Id)) <= 0) { _unitOfWork.Rollback(); throw new UserOperationException("删除失败"); } } } if (delOperaResult <= 0) { _unitOfWork.Rollback(); throw new UserOperationException("删除失败"); } _unitOfWork.Commit(); return(new JsonResponse(true)); }