Ejemplo n.º 1
0
 public void ValidarClienteExiste(int id)
 {
     ValidarId(id);
     Models.db_next_gen_booksContext context = new Models.db_next_gen_booksContext();
     Models.TbCliente tabela = context.TbCliente.FirstOrDefault(x => x.IdCliente == id);
     if (tabela == null)
     {
         throw new ArgumentException("Cliente nao encontrado");
     }
 }
Ejemplo n.º 2
0
        public async Task <ActionResult <Models.Response.AutorResponse> > DeletarAutor(int id)
        {
            try
            {
                Models.TbAutor tabela = await business.ValidarDeletarAutor(id);

                Models.db_next_gen_booksContext db = new Models.db_next_gen_booksContext();
                return(conversor.ConversorResponse(tabela));
            }
            catch (System.Exception ex)
            {
                return(new NotFoundObjectResult(new Models.Response.ErroResponse(404, ex.Message)));
            }
        }
Ejemplo n.º 3
0
 public void ValidarCadastroCliente(Models.TbCliente tabela, Models.TbLogin login)
 {
     Models.db_next_gen_booksContext context = new Models.db_next_gen_booksContext();
     foreach (Models.TbCliente item in context.TbCliente.Include(x => x.IdLoginNavigation))
     {
         if (tabela.DsEmail == item.DsEmail)
         {
             throw new ArgumentException("E-mail já cadastrado.");
         }
         if (tabela.DsCpf == item.DsCpf)
         {
             throw new ArgumentException("CPF já cadastrado.");
         }
         if (login.NmUsuario == item.IdLoginNavigation.NmUsuario)
         {
             throw new ArgumentException("Nome de usuario já cadastrado. Tente outro nome");
         }
         if (login.NmUsuario == item.IdLoginNavigation.NmUsuario)
         {
             throw new ArgumentException("Nome de usuario já cadastrado. Tente outro nome");
         }
     }
     new ValidadorLogin().ValidarSenha(login.DsSenha);
 }