Esempio n. 1
0
        public void Validar(Dominio.Entidades.Livro entidade)
        {
            var excecoes = new List <Exception>();

            if (entidade.Descricao == null)
            {
                var mensagem = string.Format(Geral.CampoObrigatorio, Geral.Descricao);

                throw new Exception(mensagem);
            }

            if (_repositorio.ObterTodos().Any(x =>
                                              x.Descricao.ToUpper().Contains(entidade.Descricao.ToUpper()) && x.Id != entidade.Id))
            {
                var mensagem = string.Format(Geral.RegistroDuplicado, Geral.Descricao);

                throw new Exception(mensagem);
            }

            if (_repositorio.ObterTodos().Any(x =>
                                              x.Titulo.ToUpper().Contains(entidade.Titulo.ToUpper()) && x.Id != entidade.Id))
            {
                var mensagem = string.Format(Geral.RegistroDuplicado, Geral.Titulo);

                throw new Exception(mensagem);
            }
        }
Esempio n. 2
0
 public LivroDto(Dominio.Entidades.Livro entidade)
 {
     Id        = entidade.Id;
     Descricao = entidade.Descricao;
 }