In my layout I have an option where I show some notifications, so include a partial layout in the layout:
@Html.Partial("_PartialNotificacoes")
@model IEnumerable<Generico.Dominio.TB_NOTIFICACAO>
@if (Model.Count() > 0)
{
foreach (var item in Model)
{
<a href="Home/LerNotificacao/@item.IDNOTIFICACAO">
<!--lista de notificações-->
<i class="fa fa-users text-aqua"></i> @Html.DisplayFor(c => item.DESCRICAO);
</a>
}
}
The problem occurs when and called a new listing page because it will also have its own IEnumerable, page call example:
public ActionResult ListarValorAssinatura()
{
var tbuscar = new ValorAssinaturaAplicacao();
var listar = tbuscar.ListarTodos();
var tbuscarNotificacao = new NotificacaoApliacao();
var retorno = tbuscarNotificacao.ListarTodos();
if (retorno != null)
{
ViewData["QtdNotificacao"] = retorno.Count();
// ViewData["ListaNotificacao"] = retorno;
}
return View(listar);
}
At this point I'm returning the list, but I'm not returning the notifications, so I have an error:
An exception of type 'System.InvalidOperationException' occurred in System.Web.Mvc.dll but was not handled in user code Additional information: The model item passed into the dictionary is of type 'System.Collections.Generic.List
1[Generico.Dominio.TB_VALOR_ASSINATURA]', but this dictionary requires a model item of type 'System.Collections.Generic.IEnumerable
1 [Generico.Domain.TB_NOTIFICACAO]'.
Options I've already tested:
@Html.Partial("_PartialNotificacoes")
@Html.Partial("~/BuscarNotificacoes/Home/_PartialNotificacoes.cshtml")
@Html.Action("BuscarNotificacoes", "Home").