I have a list of data in a table, where each row has its respective save . This button saves the date and document attached.
I have it this way:
When I click on save and call my action, it brings me all the rows, so I have to do a for
to create criteria and only save the row where I made click However, I think this practice is wrong.
Is there any way to just bring me the data from the row where I clicked on save ?
This is my current coding:
Controller Action:
public ActionResult GuardarCargoCierreAtencion(List<int> FgCargo, List<String> Mes,List<String> Periodo,
List<int> CierreAtencionId, List<String> FechaCargo, List<HttpPostedFileBase> DireccionArchivo)
{
if (HttpContext.Session["Usuario"] == null)
{
if (Request.IsAjaxRequest())
{
return JavaScript(string.Format("alert('Su sesión ha terminado, debe volver a iniciar sesión'); window.location.href='{0}'", Url.Action("IniciarSession", "Logueo")));
}
else return RedirectToAction("IniciarSession", "Logueo");
}
//EstablecimientoId = ((Usuario)Session["Usuario"]).Establecimiento.EstablecimientoId;
UsuarioID = ((Usuario)Session["Usuario"]).UsuarioId;
CierreAtencionAD CierreAtencion = new CierreAtencionAD();
CierreAtencion CierreAt = new CierreAtencion();
// ControlMedicoUdrEstablecimiento Save=new ControlMedicoUdrEstablecimiento();
int cont = 0;
if (DireccionArchivo != null)
{
foreach (HttpPostedFileBase requestFile in DireccionArchivo)
{
if (requestFile != null)
{
CierreAt = Guardar(CierreAtencionId.ElementAt(cont), FechaCargo.ElementAt(cont).ToString(), Mes.ElementAt(cont).ToString(), Periodo.ElementAt(cont).ToString(), requestFile);
// errorMensaje = errorMensaje + "<br>" + "- " + Save.error + "\n";
}
cont++;
}
}
//System.Web.HttpContext.Current.Session.Add("CierreGuardar", CierreAt);
HttpContext.Session["Error"] = CierreAt.Error;
return RedirectToAction("Index");
}