I've created the code below that generates a list. The same check whether the list contains any data recorded in it or not. If it has data, it returns a View with the list inside, if it does not have data, it returns null
.
How to do, instead of returning null
, display a warning on the page itself stating that there is no data to display?
[HttpPost]
public ActionResult Relatorio(string ocupacaoId, string instrumentoRegistroId)
{
List<ProcedimentoOcupacaoRegistro> listaprocedimentoocupacaoregistro = new ProcedimentoOcupacaoRegistro().listaProcedimentoOcupacaoRegistro(ocupacaoId, instrumentoRegistroId);
ViewBag.ocupacaoId = ocupacaoId;
ViewBag.instrumentoregistroId = instrumentoRegistroId;
if (listaprocedimentoocupacaoregistro.Count > 0)
{
return View(listaprocedimentoocupacaoregistro)
}
else
{
return null; // <<---AQUI EU QUERO ALTERAR
}
}