public JsonResult Cadastro(AlunoCadastrar alunoview) { return(Json(new Inclusao().Cadastro(alunoview))); }
public Retorno Cadastro(AlunoCadastrar alunoview) { Retorno retorno = new Retorno(); if (alunoview != null) { alunoview.cpf = alunoview.cpf.TrimStart().TrimEnd(); alunoview.email = alunoview.email.TrimStart().TrimEnd(); if (new AlunoDB().ExisteEmail(alunoview.email) && alunoview.codigo == 0) { retorno.erro = true; retorno.mensagem = "E-mail já cadastrado"; } else { Aluno aluno = new Aluno(); if (alunoview.codigo == 0) { Aluno alunoCPF = new AlunoDB().CPF(alunoview.cpf); if (alunoCPF != null) { aluno = alunoview.Atualizar(alunoCPF); aluno.Alterar(); } else { aluno = alunoview.Retornar(); aluno.Salvar(); } } else { aluno = alunoview.Atualizar(new AlunoDB().Buscar(alunoview.codigo)); aluno.Alterar(); } retorno.erro = false; retorno.mensagem = "Redirecionando..."; retorno.id = new AlunoDB().CPF(alunoview.cpf).codigo; string _ga = Cookies_ga(); if (_ga != null && _ga != "") { new Aluno_navegacaoDB().Existe(aluno, _ga); //seleciona dos os _ga do periodo de lead (newsletter) foreach (var n in new Newsletter_navegacaoDB().ListarEmail(aluno.email)) { new Aluno_navegacaoDB().Existe(aluno, n._ga); } } } } else { retorno.erro = true; retorno.mensagem = "Conteúdo vazio"; } return(retorno); }