public ActionResult Asignar(int pRolId, string pRoles) { var lst = pRoles.Split(','); RolMenuBL.EjecutarSql("DELETE FROM MAESTRO.RolMenu WHERE RolId=" + pRolId.ToString()); foreach (var item in lst) { RolMenuBL.Crear(new RolMenu() { RolId = pRolId, MenuId = int.Parse(item) }); } return(Json(true, JsonRequestBehavior.AllowGet)); }
public ActionResult ObtenerRolMenu(int pRolId) { var rol = RolBL.Obtener(pRolId); var menus = (from of in MenuBL.Listar(x => x.IndPadre.Value == false) join us in RolMenuBL.Listar(x => x.RolId == pRolId) on of.MenuId equals us.MenuId into factDesc from fd in factDesc.DefaultIfEmpty() select new { of.MenuId, Denominacion = of.Modulo + " - " + of.Denominacion, Asignado = (fd == null) ? 0 : 1 } ).ToList(); return(Json(new { Rol = rol, Menus = menus.OrderBy(x => x.Denominacion) }, JsonRequestBehavior.AllowGet)); }