public async Task ExcluirModeloAsync(long modeloId) { var modelo = await _modeloRepository.ObterPorIdAsync(modeloId); if (modelo == null) { throw new EntityNotFoundException(typeof(Modelo).Name, modeloId); } if (await _modeloRepository.ModeloPossuiPatrimonio(modelo.ModeloId)) { throw new DomainException("Este modelo não pode ser excluido, pois o mesmo possui patrimonios vinculados"); } modelo.Excluir(); await _modeloRepository.ExcluirAsync(modelo); }