Created
November 14, 2022 20:51
-
-
Save carloswm85/cdff0818ef2078a87e8a91e53e1ceb8c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 1) Recupero los permisos en el controlador a través de un web service | |
System.Collections.ObjectModel.Collection<ImportadorRegalias.WebServicesAccess.Permisos> ListPermisos = oServicio.obtainModulosPermisosBySession(idSesion, 16); | |
List<int> ListaPermisos = new List<int>(); | |
foreach (ImportadorRegalias.WebServicesAccess.Permisos oPermiso in ListPermisos) | |
ListaPermisos.Add(oPermiso.IdModulo); | |
HttpContext.Current.Session["ListaPermiso"] = ListaPermisos; | |
// 2) En el view, Razor, recupero los permisos, y doy visibilidad a los elementos que me interesa según los módulos que habilitan los permisos. | |
foreach (ServiceAccess.Permisos oPermiso in _ListPermisos) | |
{ | |
int idModulo = oPermiso.IdModulo; | |
switch (idModulo) { | |
case 13: //Operaciones DDJJ | |
liDDJJ.Visible = true; | |
liDDJJCEP.Visible = true; | |
liDDJJCP.Visible = true; | |
break; | |
case 14: //Consultas | |
liInformes.Visible = true; | |
liListados.Visible = true; | |
break; | |
default: | |
break; | |
} | |
// 3) En base a las condiciones de arrivba, muestro o no los elementos HTML que necesito. | |
@{ | |
switch(id) | |
{ | |
case "test": | |
// Use the text block below to separate html elements from code | |
<text> | |
<h1>Test Site</h1> | |
</text> | |
break; // Always break each case | |
case "prod": | |
<text> | |
<h1>Prod Site</h1> | |
</text> | |
break; | |
default: | |
<text> | |
<h1>WTF Site</h1> | |
</text> | |
break; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment