Exemplo n.º 1
0
        public int Excluir(long Id)
        {
            _logger.LogDebug("Delete");
            try
            {
                _contexto.Remove(ObterPorId(Id));
                var result = _contexto.SaveChanges();

                _logger.LogDebug($"Delete: entity with id({Id}) deleted");

                return(result);
            }
            catch (DbException ex)
            {
                _logger.LogError(ex, $"Delete Error: {ex.Message}");
                throw;
            }
        }
Exemplo n.º 2
0
        public bool ExcluirValidador(Guid idValidacao)
        {
            try
            {
                var validacao = _contexto.Set <EmailValidacao>().SingleOrDefault(x => x.Id == idValidacao);

                if (validacao != null)
                {
                    _contexto.Remove(validacao);
                    _contexto.SaveChanges();
                    return(true);
                }

                return(false);
            }
            catch (DbUpdateException ex)
            {
                _logger.LogError(ex, $"CriarValidador: {ex.Message}");
                throw;
            }
        }