public ActionResult Edit(int id, TbPapelesCarro a) { try { var context = HttpContext.RequestServices.GetService(typeof(riviera_businessContext)) as riviera_businessContext; var objectEdit = context.TbPapelesCarro.FirstOrDefault(pa => pa.IdCarro == a.IdCarro); if (objectEdit != null) { objectEdit.Baja = a.Baja; objectEdit.FactOrigen = a.FactOrigen; objectEdit.FechaUlltimaVerificacion = a.FechaUlltimaVerificacion; objectEdit.IdCarro = a.IdCarro; objectEdit.IdEmisor = a.IdEmisor; objectEdit.IdEstado = a.IdEstado; objectEdit.Mes = a.Mes; objectEdit.RefactCompleta = a.RefactCompleta; objectEdit.Repuve = a.Repuve; objectEdit.Tenencias4Anos = a.Tenencias4Anos; objectEdit.Transunionfolio = a.Transunionfolio; objectEdit.Verificacion = a.Verificacion; context.TbPapelesCarro.Update(objectEdit); context.SaveChanges(); TbLineaTiempo linea = new TbLineaTiempo(); linea.IdCarro = a.IdCarro; linea.Fecha = DateTime.Today; linea.IdEstado = 17; context.TbLineaTiempo.Add(linea); context.SaveChanges(); } return(RedirectToAction(nameof(Index))); } catch { return(View()); } }
public ActionResult Create(TbPapelesCarro a) { try { var context = HttpContext.RequestServices.GetService(typeof(riviera_businessContext)) as riviera_businessContext; context.TbPapelesCarro.Add(a); context.SaveChanges(); TbLineaTiempo linea = new TbLineaTiempo(); linea.IdCarro = a.IdCarro; linea.Fecha = DateTime.Today; linea.IdEstado = 16; context.TbLineaTiempo.Add(linea); context.SaveChanges(); return(RedirectToAction(nameof(Index))); } catch { return(View()); } }