private void LoadUserMenuForUser(Sec_Users _dbUser) { foreach (var dbGroup in _dbUser.Sec_Groups) { foreach (var dbGroupRight in dbGroup.Sec_GroupRights) { MenuItem menuItem = new MenuItem(); menuItem.FromDbMenuItem(dbGroupRight.Sec_MainMenu); menuItem.FormAllowedFunctions = menuItem.FormAllowedFunctions & dbGroupRight.AllowedFunctions; var existMenuItem = this.UserMenuItems.Find(m => m.MenuID == menuItem.MenuID); if (existMenuItem == null) this.UserMenuItems.Add(menuItem); else { existMenuItem.FormAllowedFunctions = existMenuItem.FormAllowedFunctions & dbGroupRight.AllowedFunctions; } } } }
private void LoadUserMenu(Sec_Users _dbUser) { if (_dbUser.IsAdmin == false) this.LoadUserMenuForUser(_dbUser); else this.LoadUserMenuForAdminUser(_dbUser); }
private void LoadUserMenuForAdminUser(Sec_Users _dbUser) { NewAppsCnn newAppsCnn = new NewAppsCnn(AppSettings.CrAppSettings.NewAppsConnectionString); var dbMenuItems = from m in newAppsCnn.Sec_MainMenu select m; foreach (var dbMenuItem in dbMenuItems) { MenuItem menuItem = new MenuItem(); menuItem.FromDbMenuItem(dbMenuItem); this.UserMenuItems.Add(menuItem); } }
public void ToDbUser(Sec_Users _dbUser) { _dbUser.UserLogin = this.UserLogin; _dbUser.Name_Ara = this.Name_Ara; _dbUser.Name_Eng = this.Name_Eng; _dbUser.Password = this.Password; _dbUser.IsAdmin = this.IsAdmin; }
public void SaveDbUserGroups(Sec_Users _dbUser, NewAppsCnn newAppsCnn) { // Add New User Groups foreach (var group in this.Groups) { var dbUserGroups = _dbUser.Sec_Groups.Where(g => g.GroupID == group.GroupID); if (dbUserGroups.Count() == 0) { var dbGroup = newAppsCnn.Sec_Groups.First(g => g.GroupID == group.GroupID); _dbUser.Sec_Groups.Add(dbGroup); } } // Delete User Groups foreach (var dbGroup in _dbUser.Sec_Groups.ToList()) { var group = this.Groups.Find(g => g.GroupID == dbGroup.GroupID); if (group == null) _dbUser.Sec_Groups.Remove(dbGroup); } }
public DataSaveResult Save() { Sec_Users dbUser; try { NewAppsCnn newAppsCnn = new NewAppsCnn(AppSettings.CrAppSettings.NewAppsConnectionString); var dbUsers = from u in newAppsCnn.Sec_Users where u.UserID == this.UserID select u; if (dbUsers.Count() > 0) { dbUser = dbUsers.First(); this.ToDbUser(dbUser); this.SaveDbUserGroups(dbUser, newAppsCnn); } else { dbUser = new Sec_Users(); this.ToDbUser(dbUser); this.SaveDbUserGroups(dbUser, newAppsCnn); newAppsCnn.Sec_Users.Add(dbUser); } newAppsCnn.SaveChanges(); Audit.AddDataAudit(Audit.AuditActionTypes.AddNew, "Sec_Users", this); this.FromDbUser(dbUser); return new DataSaveResult() { SaveStatus = true }; } catch (Exception ex) { return new DataSaveResult() { SaveStatus = false, ErrorMessage = ex.Message }; } }
public void LoadDbUserGroups(Sec_Users _dbUser) { Groups.Clear(); foreach (var dbGroup in _dbUser.Sec_Groups) { Group group = new Group(); group.FromDbGroup(dbGroup); this.Groups.Add(group); } }
public void FromDbUser(Sec_Users _dbUser) { this.UserID = _dbUser.UserID; this.UserLogin = _dbUser.UserLogin; this.Name_Ara = _dbUser.Name_Ara; this.Name_Eng = _dbUser.Name_Eng; this.Password = _dbUser.Password; this.IsAdmin = _dbUser.IsAdmin; this.IsNew = false; }