what can I do to save what that where generates every time I enter and then show it in the view, as well as saving the FirstOrDefault that every time I enter it I keep it in that add
if (DedudccionesId != null)
{
IList<string> Deducciones = new List<string>();
for (int i = 0; i < DedudccionesId.Length; i++)
{
int idDeduccion = DedudccionesId[i];
var Deduccion = db.Tbl_Deducciones.FirstOrDefault(t => t.DedId == idDeduccion);
Deducciones.Add(Deduccion.DedDescripcion);
if (Deduccion.DedTipo == "No Frecuente")
{
var DeduccionesEmpleados = db.Con_DetalleDeduccionesEmpleado.Where(t => t.DedId == idDeduccion && t.AgeId == tbl_Agencia.AgeId && t.AreId == tbl_Area.AreId && DbFunctions.TruncateTime(t.DetDedEmpFecha) >= FechaDesde && DbFunctions.TruncateTime(t.DetDedEmpFecha) <= FechaHasta && t.HisLabEstadoEmpleado == true);
ViewBag.DeduccionesEmpleados = DeduccionesEmpleados.ToList(); // muestra las deducciones asignadas a los empleados
}
if (Deduccion.DedTipo == "Frecuente")
{
// var DeducionesFijasEmpleado = db.Con_DeduccionesFijasEmpleado.Where(t => t.DedId == tbl_Deducciones.DedId && t.AgeId == tbl_Agencia.AgeId && t.AreId == tbl_Area.AreId && t.HisLabEstadoEmpleado == true);
var DeducionesFijasEmpleado = db.Con_DeduccionesFijasEmpleado.Where(t => t.AgeId == tbl_Agencia.AgeId && t.AreId == tbl_Area.AreId && t.HisLabEstadoEmpleado == true);
ViewBag.DeducionesFijasEmpleado = DeducionesFijasEmpleado.ToList(); // muestra las deducciones No frecuentes asignadas a los empleados
}
}
ViewBag.Deducciones = Deducciones.ToList();
}