public ActionResult AddEditRoles(int?RolId) { AddEditRolesViewModel objViewModel = new AddEditRolesViewModel(); objViewModel.CargarDatos(RolId); return(View(objViewModel)); }
public ActionResult AddEditRoles(AddEditRolesViewModel objViewModel) { LBPEntities context = new LBPEntities(); Roles objRol = new Roles(); if (objViewModel.RolId.HasValue) { objRol = context.Roles.FirstOrDefault(X => X.RolId == objViewModel.RolId); objRol.Acronimo = objViewModel.Acronimo; objRol.Descripcion = objViewModel.Descripcion; } else { objRol.Acronimo = objViewModel.Acronimo; objRol.Descripcion = objViewModel.Descripcion; context.Roles.Add(objRol); } context.SaveChanges(); return(RedirectToAction("LstRoles")); }