Good evening guys. I have a project for a school that records student data and its occurrences. going straight to my problem: What happens is that I have a page where to show the new occurrences that were generated in the system by a Partial that I created to show this type of data. This Partial I am calling it in the view Index of the Home controller, that even in it I made an action result to search in the table of occurrences all the occurrences that have in the system and show in that Partial. At the level of knowledge, this Home controller, has nothing, only renders a view with the options that each user can access depending on his profile. But what is happening to me is, in a certain profile, I want to log in, besides showing his options show this Partial with the occurrences, only that soon after the user was supposed to be shown the view Index and with her I am trying to render a partial, but I do not know how to do it. I am trying to do this, but I do not know how to do it. Could someone help me?
Controller (Here I will show only ActionResult to speed up)
private EntidadesContext db;
public HomeController(EntidadesContext contexto)
{
this.db = contexto;
}
public ActionResult PartialOcorrencias(long? id, int? pagina)
{
List<Ocorrencia> resultado = db.Ocorrencias.Include(o => o.Aluno).ToList();
int paginaTamanho = 25;
int paginaNumero = (pagina ?? 1);
var ocorrencias = resultado;
return PartialView("PartialOcorrencias", ocorrencias.ToPagedList(paginaNumero, paginaTamanho));
}
View (Home / Index)
@using CEF01.Filters
@{
ViewBag.Title = "Olá";
Verify.setVerify(Session[".PermissionCookie"].ToString());
}
<div class="container">
<div class="jumbotron">
<h2 class="text-center">Bem Vindo ao <i>Sistema de Gestão de Alunos - SGA</i></h2>
<br />
<article>
<h3> Olá, @User.Identity.Name</h3>
</article>
@if (Verify.isProfessor())
{
@Html.Partial("_PartialProfessor")
}
else if (Verify.isCoordenador())
{
@Html.Partial("_PartialCoordenador")
@Html.Partial("PartialOcorrencias")
}
else if (Verify.isAdmin())
{
@Html.Partial("_PartialProfessor")
@Html.Partial("_PartialCoordenador")
@Html.Partial("_PartialAdministrador")
}
<h3>Centro de Ensino Fundamental 01 - Riacho Fundo II</h3>
</div>
</div>
Partial (PartialOcorrencias, and it is in that foreah that he alleges the error)
@*@model IEnumerable<CEF01.Models.Ocorrencia>*@
@model PagedList.IPagedList<CEF01.Models.Ocorrencia>
@using PagedList.Mvc;
<link href="~/Content/PagedList.css" rel="stylesheet" type="text/css" />
<table>
<tr>
<th>
@*@Html.DisplayNameFor(model => model.Aluno.Nome)*@
Nome do Aluno
</th>
</tr>
@foreach (var item in Model)
{
<tr>
<td>
@Html.DisplayFor(modelItem => item.Aluno.Nome)
@Html.ActionLink("Resolver", "Edita", new { id = item.Id })
</td>
</tr>
}
</table>
Pagina @(Model.PageCount < Model.PageNumber ? 0 : Model.PageNumber) de @Model.PageCount
@Html.PagedListPager(Model, pagina => Url.Action("PartialOcorrencias", new { pagina, sortOrder = ViewBag.CurrentSort, currentFilter = ViewBag.CurrentFilter }))