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 void SalvaMenuUtente(string UIDUSER, int[] idMenu) { SecurityDS ds = new SecurityDS(); using (SecurityBusiness bSecurity = new SecurityBusiness()) { bSecurity.FillUserMenu(UIDUSER, ds); if (idMenu == null) { foreach (SecurityDS.RW_USER_MENURow row in ds.RW_USER_MENU.ToList()) { row.Delete(); } bSecurity.SalvaMenuUtente(ds); return; } foreach (SecurityDS.RW_USER_MENURow row in ds.RW_USER_MENU.Where(x => !idMenu.Contains((int)x.IDMENU)).ToList()) { row.Delete(); } foreach (int idm in idMenu) { SecurityDS.RW_USER_MENURow row = ds.RW_USER_MENU.Where(x => x.RowState != System.Data.DataRowState.Deleted && x.IDMENU == idm).FirstOrDefault(); if (row == null) { SecurityDS.RW_USER_MENURow newrow = ds.RW_USER_MENU.NewRW_USER_MENURow(); newrow.IDMENU = idm; newrow.UIDUSER = UIDUSER; ds.RW_USER_MENU.AddRW_USER_MENURow(newrow); } } bSecurity.SalvaMenuUtente(ds); } }
public void SalvaMenuUtente(string account, int[] idMenu) { SecurityDS ds = new SecurityDS(); using (SecurityBusiness bSecurity = new SecurityBusiness()) { bSecurity.FillAccountMenu(account, ds); if (idMenu == null) { foreach (SecurityDS.ABILITAZIONIRow row in ds.ABILITAZIONI.ToList()) { row.Delete(); } bSecurity.SalvaMenuUtente(ds); return; } foreach (SecurityDS.ABILITAZIONIRow row in ds.ABILITAZIONI.Where(x => !idMenu.Contains((int)x.IDMENU)).ToList()) { row.Delete(); } foreach (int idm in idMenu) { SecurityDS.ABILITAZIONIRow row = ds.ABILITAZIONI.Where(x => x.RowState != System.Data.DataRowState.Deleted && x.IDMENU == idm).FirstOrDefault(); if (row == null) { SecurityDS.ABILITAZIONIRow newrow = ds.ABILITAZIONI.NewABILITAZIONIRow(); newrow.IDMENU = idm; newrow.UTENTE = account; ds.ABILITAZIONI.AddABILITAZIONIRow(newrow); } } bSecurity.SalvaMenuUtente(ds); } }
public void RimuoviAccount(string account) { SecurityDS ds = new SecurityDS(); using (SecurityBusiness bSecurity = new SecurityBusiness()) { bSecurity.FillAccountMenu(account, ds); foreach (SecurityDS.ABILITAZIONIRow row in ds.ABILITAZIONI.ToList()) { row.Delete(); } bSecurity.SalvaMenuUtente(ds); return; } }