public ActionResult Procurar(string procurarPor, string criterio)
        {
            AlunoBLL alunoBll = new AlunoBLL();

            if (procurarPor == "Email")
            {
                Aluno aluno = alunoBll.getAlunos().SingleOrDefault(x => x.Email == criterio || criterio == null);
                return(View(aluno));
            }
            else
            {
                Aluno aluno = alunoBll.getAlunos().SingleOrDefault(x => x.Nome == criterio || criterio == null);
                return(View(aluno));
            }
        }
        //Get
        public ActionResult Edit(int id)
        {
            AlunoBLL alunoBll = new AlunoBLL();
            Aluno    aluno    = alunoBll.getAlunos().Single(x => x.Id == id);

            return(View(aluno));
        }
Exemplo n.º 3
0
        public ActionResult Details(int id)
        {
            AlunoBLL alunoBLL = new AlunoBLL();
            Aluno    aluno    = alunoBLL.getAlunos().Single(x => x.Id == id);

            return(View(aluno));
        }
Exemplo n.º 4
0
        // GET: Home
        public ActionResult Index()
        {
            AlunoBLL _aluno = new AlunoBLL();

            List <Aluno> alunos = _aluno.getAlunos().ToList();


            return(View("Index", alunos));
        }
        // GET: Home
        public ActionResult Index()
        {
            //Criei instancia da classe AlunoBLL
            AlunoBLL _aluno = new AlunoBLL();

            //Usando o metodo GetAluno, que entra no BD e retorna a lista de alunos
            List <Aluno> alunos = _aluno.getAlunos().ToList();

            return(View(alunos));
        }
Exemplo n.º 6
0
        // GET: Home
        public ActionResult Index()
        {
            //criei uma instância da classe AlunoBLL
            AlunoBLL _aluno = new AlunoBLL();

            //estou usando o método getAlunos e retornando uma lista de alunos
            List <Aluno> alunos = _aluno.getAlunos().ToList();

            //passando para view
            return(View(alunos));
        }
Exemplo n.º 7
0
        public ActionResult Edit_Post([Bind(Exclude = "Nome")] Aluno aluno)
        {
            AlunoBLL alunobll = new AlunoBLL();

            //bucando o nome, já que no Bind não retorna o NOME
            aluno.Nome = alunobll.getAlunos().Single(x => x.Id == aluno.Id).Nome;

            if (ModelState.IsValid)
            {
                alunobll.AtualizarAluno(aluno);
                return(RedirectToAction("Index"));
            }
            return(View(aluno));
        }
        public ActionResult Edit_Post([Bind(Exclude = "Nome")] Aluno aluno)
        {
            AlunoBLL alunobll = new AlunoBLL();

            aluno.Nome = alunobll.getAlunos().Single(x => x.Id == aluno.Id).Nome;
            //Aluno aluno = alunobll.getAlunos().Single(x => x.Id == id);
            //UpdateModel(aluno,null,null, excludeProperties: new[] { "Nome" });

            if (ModelState.IsValid)
            {
                alunobll.AtualizarAluno(aluno);
                return(RedirectToAction("Index"));
            }
            return(View(aluno));
        }
        //public ActionResult Edit_Post([Bind(Include ="Id, Email, Idade, DataInscricao, Sexo")]Aluno aluno) //Protegendo com Bind, O nome vem Null dessa forma
        public ActionResult Edit_Post([Bind(Exclude = "Nome")] Aluno aluno) //Protegendo com Bind, O nome vem Null dessa forma
        {
            AlunoBLL alunoBll = new AlunoBLL();

            aluno.Nome = alunoBll.getAlunos().Single(x => x.Id == aluno.Id).Nome; //Pegar a informacao do nome para preencher e nao deixar editar


            //Aluno aluno = alunoBll.getAlunos().Single(x => x.Id == id);
            //UpdateModel(aluno,null, null, excludeProperties: new[] { "Nome" });

            if (ModelState.IsValid)
            {
                alunoBll.AtualizarAluno(aluno);

                return(RedirectToAction("Index"));
            }
            return(View(aluno));
        }