I can not print the bank data in my indexView

0

Good afternoon, I'm not able to list in my view Index the data already registered in the bank.

My method in the Controller class looks like this:

  public class AlunosController : Controller
    {

        public ActionResult Index()
        {


            return View();
        }

        #region Método que lista todos Alunos
        public JsonResult ListarAlunos()
        {
            using (var db = new ConexaoTesteGitMvc())
            {
                List<Aluno> listarAlunos = db.Alunos.ToList();

                return Json(listarAlunos, JsonRequestBehavior.AllowGet);
            }
        }

My template class has the following data:

public class Aluno
{
    public int AlunoId { get; set; }
    public string Nome { get; set; }
    public byte[] Imagem { get; set; }
    public string ImagemTipo { get; set; }
    public int CursoId { get; set; }

    [ForeignKey("CursoId")]
    public virtual Curso Curso { get; set; }

}

and my view that will list:

<div class="container" ng-controller="alunosCtrl">
    <div class="panel panel-info">
        <div class="panel-heading">Listagem de Alunos</div>

        <div class="panel-body">
            <button type="button" class="btn btn-info" data-target="#inserirAlunoNovo" data-toggle="modal">
                <span class="glyphicon glyphicon-plus-sign"></span>
            </button>
        </div>

        <table class="table table-bordered">
            <thead style="background-color: lightsteelblue">
                <tr>
                    <th class="text-center">AlunoId</th>
                    <th class="text-center">Nome</th>
                    <th class="text-center">CursoId</th>
                </tr>
            </thead>

            <tbody>
                <tr ng-repeat="aln in Alunos">
                    <td class="text-center">{{aln.AlunoId}}</td>
                    <td class="text-center">{{aln.Nome}}</td>
                    <td class="text-center">{{aln.CursoId}}</td>
                    <td style="width: 200px;">
                        <a href="#" data-target="#AtualizarAluno" ng-click="atualizarAlunoPorId(aln)"><span class="glyphicon glyphicon-edit"></span></a>
                        <a href="#" data-target="#DeletarAluno" data-toggle="modal" id="btnDeletar" class="btn btn-danger" ng-click="deletarAlunoPorId(aln)"><span></span></a>
                    </td>
                </tr>
            </tbody>
        </table>
        @*  inicio modal - Inserir Aluno*@
        <div class="modal" id="InserirAlunoNovo" role="dialog">
            <div class="modal-dialog">
                <div class="modal-content">
                    <div class="modal-header">
                        <h3 class="text-info">Inserir Aluno novo</h3>
                    </div>
                    <div class="modal-body">
                        <form class="form-horizontal" name="IncluirNovoAlunoForm">
                            <div class="form-group">
                                <input class="form-control" readonly="readonly" name="alunoId" type="hidden" placeholder="Id Aluno" />
                            </div>
                            <div class="form-group">
                                <input form="form-control" type="text" name="nome" ng-model="nome" placeholder="Nome" />
                            </div>
                            <div class="form-group">
                                <input class="form-control" type="text" name="cursoId" ng-model="cursoId" placeholder="Curso" />
                            </div>
                        </form>
                    </div>
                    <div class="modal-footer">
                        <button type="button" class="btn btn-primary" id="btnIncluir" data-dismiss="modal" ng-click="inserirAlunoNovo()">Incluir</button>
                        <button type="button" class="btn btn-default" data-dismiss="modal" ng-click="limparCampos()">Fechar</button>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
@section scripts{
    <script src="~/App_AngularJs/Alunos/Module.js"></script>
    <script src="~/App_AngularJs/Alunos/Service.js"></script>
    <script src="~/App_AngularJs/Alunos/Controller.js"></script>
}
    
asked by anonymous 03.02.2018 / 21:56

0 answers