0
Can someone help me with this?
Must declare the scalar variable "@hospitalId".
Pendenciacontroller:
public async Task<ActionResult> Index()
{
if (!Cookies.Exists("hid"))
return RedirectToAction("Index", "Login", new { area = "Entrar" });
var hospitalId = int.Parse(Cookies.GetCookie("hid"));
var lista = await Dia1Service.GetPendenciasByUser(hospitalId);
return View(lista);
}
Dia1service:
public async Task<IEnumerable<Dia1>> GetPendenciasByUser(int hospitalId)
{
return await _dia1Repository.GetPendenciasByUser(hospitalId);
}
**Dia1Repository:**
public async Task<IEnumerable<Dia1>> GetPendenciasByUser(int hospitalId)
{
const string query = @"SELECT d1.PatientId AS Id,
c.inpac AS Iniciais,
CASE
WHEN (CONVERT(DATE,r.RandomizacaoData , 103) = CONVERT(DATE,d1.dtd1 , 103)) OR d1.dtd1 IS NULL
THEN r.RandomizacaoData
WHEN (CONVERT(DATE,r.RandomizacaoData , 103) < CONVERT(DATE,d1.dtd1 , 103))
THEN CONVERT(datetime,d1.dtd1 , 103)
ELSE r.RandomizacaoData
END DataRandomizacao
FROM Basics_Dia1 d1
LEFT JOIN Basics_Cadastro c ON c.PatientId = d1.PatientId AND d1.StatPree = 1
LEFT JOIN basics_Randomizacao r ON r.PatientId = c.PatientId AND r.CentroId = c.HospitalId
WHERE c.HospitalId = @hospitalId AND c.StatPree = 1 AND c.Removido = 0";
var cn = Db.Database.Connection;
var lista = await cn.QueryAsync<Dia1>(query, new { Hospital = hospitalId });
return lista;
}
Thanks guy I didn’t even notice, my eyes are hooked already
– Leonardo Macedo
It happens. You need to accept the answer.
– Jean Gustavo Prates