public void CreaAccount(string account, bool copia, string daCopiare) { SecurityDS ds = new SecurityDS(); using (SecurityBusiness bSecurity = new SecurityBusiness()) { if (copia) { bSecurity.FillAccountMenu(daCopiare, ds); List <decimal> menu = ds.ABILITAZIONI.Where(x => x.UTENTE == daCopiare).Select(x => x.IDMENU).Distinct().ToList(); foreach (decimal idm in menu) { SecurityDS.ABILITAZIONIRow newrow = ds.ABILITAZIONI.NewABILITAZIONIRow(); newrow.IDMENU = idm; newrow.UTENTE = account; ds.ABILITAZIONI.AddABILITAZIONIRow(newrow); } } else { bSecurity.FillMenu(ds); foreach (int idm in ds.MENU.Where(x => x.IsAZIONENull()).Select(x => x.IDMENU)) { SecurityDS.ABILITAZIONIRow newrow = ds.ABILITAZIONI.NewABILITAZIONIRow(); newrow.IDMENU = idm; newrow.UTENTE = account; ds.ABILITAZIONI.AddABILITAZIONIRow(newrow); } } bSecurity.SalvaMenuUtente(ds); } }
public List <MenuModel> CreateMenuModel(string account, bool mostratutto) { SecurityDS ds = new SecurityDS(); using (SecurityBusiness bSecurity = new SecurityBusiness()) { bSecurity.FillMenu(ds); bSecurity.FillAccountMenu(account, ds); } List <int> idMenuAbilitati = ds.ABILITAZIONI.Where(x => x.UTENTE == account).Select(x => (int)x.IDMENU).ToList(); List <MenuModel> menu = new List <MenuModel>(); List <SecurityDS.MENURow> menuDaVisualizzare = ds.MENU.Where(x => x.IsIDMENUPADRENull()).ToList(); if (!mostratutto) { menuDaVisualizzare = ds.MENU.Where(x => x.IsIDMENUPADRENull() && x.IsAZIONENull()).ToList(); } foreach (SecurityDS.MENURow row in menuDaVisualizzare) { MenuModel elementoMenu = CreaMenu(ds, row.IDMENU, idMenuAbilitati, mostratutto); menu.Add(elementoMenu); } return(menu); }
public bool VerificaAbilitazioneUtente(string controller, string action, string account) { using (SecurityBusiness bSecurity = new SecurityBusiness()) { SecurityDS ds = new SecurityDS(); bSecurity.FillAccountMenu(account, ds); bSecurity.FillMenu(ds); string azione = string.Format("/{0}/{1}", controller.ToUpper(), action.ToUpper()); SecurityDS.MENURow menu = ds.MENU.Where(x => !x.IsHREFNull() && x.HREF.ToUpper() == azione).FirstOrDefault(); if (menu == null) { return(true); // non esiste nella tabella manu allora accesso libero } return(ds.ABILITAZIONI.Any(x => x.IDMENU == menu.IDMENU)); } }
public List <MenuModel> CreateMenuModel(string UIDUSER) { SecurityDS ds = new SecurityDS(); using (SecurityBusiness bSecurity = new SecurityBusiness()) { bSecurity.FillMenu(ds); bSecurity.FillUserMenu(UIDUSER, ds); } List <int> idMenuAbilitati = ds.RW_USER_MENU.Where(x => x.UIDUSER == UIDUSER).Select(x => (int)x.IDMENU).ToList(); List <MenuModel> menu = new List <MenuModel>(); foreach (SecurityDS.RW_MENURow row in ds.RW_MENU.Where(x => x.IsIDMENUPADRENull())) { MenuModel elementoMenu = CreaMenu(ds, row.IDMENU, idMenuAbilitati); menu.Add(elementoMenu); } return(menu); }