1
I’m trying to do a pendant counter to my system, only it’s giving error, at the time of calculating, someone could help me?
Error in . Count as you can see in the picture below.
My Controller
public async Task<ActionResult> Index()
{
if (!Cookies.Exists("hid"))
return RedirectToAction("Index", "Login", new { area = "Entrar" });
var hospitalId = int.Parse(Cookies.GetCookie("hid"));
var listaDia1 = await Dia1Service.GetPendenciasByUser(hospitalId);
var listaDia2 = await Dia2Service.GetPendenciasByUser(hospitalId);
var listaDia3 = await Dia3Service.GetPendenciasByUser(hospitalId);
var listaDia7 = await Dia7Service.GetPendenciasByUser(hospitalId);
var lista90Dias = await Dados90DiasService.GetPendenciasByUser(hospitalId);
var listaAlta = await AltaUTIService.GetPendenciasByUser(hospitalId);
var listaDemografia = await DemografiaContatosService.GetPendenciasByUser(hospitalId);
var listaDadosBasais = await DadosBasaisService.GetPendenciasByUser(hospitalId);
ViewBag.listaD1 = listaDia1;
ViewBag.listaD2 = listaDia2;
ViewBag.listaD3 = listaDia3;
ViewBag.listaD7 = listaDia7;
ViewBag.lista90d = lista90Dias;
ViewBag.listaAlta = listaAlta;
ViewBag.listaDeC = listaDemografia;
ViewBag.listaDb = listaDadosBasais;
return View();
}
My Contact at Pendenciafilter.Cs
void IActionFilter.OnActionExecuted(ActionExecutedContext filterContext)
{
AtualizarNotificacoes(filterContext);
}
private void AtualizarNotificacoes(ActionExecutedContext filterContext)
{
if (string.IsNullOrEmpty(Cookies.GetCookie("uid"))) return;
var hospitalId = int.Parse(Cookies.GetCookie("hid"));
// Pegar todas as notificações deste usuario
var altaUtiPendencias = new AltaUtiService().GetPendenciasByUser(hospitalId).Count();
var dia1Pendencias = new Dia1Service().GetPendenciasByUser(hospitalId).ToString();
filterContext.Controller.ViewBag.QtdPendencias = altaUtiPendencias + dia1Pendencias;
}
And in the void method Iactionfilter.Onactionexecuted(Actionexecutedcontext filterContext) { Updatedscripts(filterContext); } I need to move something?
– Leonardo Macedo
@Leonardomacedo ready
– Tobias Mesquita
Tobias can you take a look at this picture? http://prntscr.com/ix2hgk
– Leonardo Macedo
@Leonardomacedo was my mistake, Action Filters asynchronous are present only in Core. Then you’ll have to make a synchronous call to the asynchronous method.
– Tobias Mesquita
Instead of (Actionexecutedcontext contex) it would be (Actionexecutedcontext filterContext) correct?
– Leonardo Macedo
I made the fix on my code, apparently it worked, only at the time I run my system. It keeps loading... and doesn’t open the system, but there’s no error. I have in my system a Filterconfig.Cs would I have to touch it too in relation to this? public Static void Registerglobalfilters(Globalfiltercollection Filters) { Filters.Add(new Pendenciafilter(); }
– Leonardo Macedo
It can be a deadlock in the asynchronous call, the ideal would be to call a synchronous version of the query. Not to mention that these services of yours smell like trouble to me.
– Tobias Mesquita
you have some example of how I perform this modification?
– Leonardo Macedo