I am calling a method that according to the final result shows a message or another by means of tempdata
var departamentos = Repositorios.RepositorioPersonal.getDepartamentos();
if (departamentos.Count > 0)
{
foreach (var grabar in departamentos)
{
Departamento dept = new Departamento();
dept.Descripcion = grabar.Name;
dept.IdDepartamentoNuo = grabar.Id;
db.Departamento.Add(dept);
}
db.SaveChanges();
TempData["MsgType"] = "success";
TempData["Msg"] = "Departamentos actualizados.";
}
else
{
TempData["MsgType"] = "success";
TempData["Msg"] = "No hay departamentos nuevos.";
}
return RedirectToAction("Index");
But the messages do not show them. In other methods I have this same and if it works perfectly, I do not know if there is something wrong that I do not see.