public ActionResult Create(CtGrupomovi e) { try { var currentUser = HttpContext.Session.GetString("nomUsuario"); var context = HttpContext.RequestServices.GetService(typeof(rodlpContext)) as rodlpContext; e.Status = 1; e.Usuario = currentUser; context.CtGrupomovi.Add(e); context.SaveChanges(); return(RedirectToAction(nameof(Index))); } catch { return(View()); } }
public ActionResult Edit(CtGrupomovi empEdit) { try { var context = HttpContext.RequestServices.GetService(typeof(rodlpContext)) as rodlpContext; var objectEdit = context.CtGrupomovi.FirstOrDefault(em => em.IdGrupoMov == empEdit.IdGrupoMov); var currentUser = HttpContext.Session.GetString("nomUsuario"); if (objectEdit != null) { objectEdit.Descripcion = empEdit.Descripcion; objectEdit.Usuario = currentUser; context.CtGrupomovi.Update(objectEdit); context.SaveChanges(); } return(RedirectToAction(nameof(Index))); } catch { return(View()); } }