public void AddNewPermissionGroup(Permissions_Group p) { try { DB.AddToPermissions_Groups(p); } catch (Exception) { throw new Exception("Lỗi thêm mức quyền"); } }
public void AddNewGroup(UserGroup userGroup) { try { DB.AddToUserGroups(userGroup); List<Permission> permissionList = FindPermissionsByLevel(userGroup.Level.Value).ToList(); var permissionGroupIDList = permissionList.Select(permission => permission.ID).ToList(); foreach (var permissdionID in permissionGroupIDList) { var permissiongroup = new Permissions_Group { GroupID = userGroup.ID, PermissionID = permissdionID }; AddNewPermissionGroup(permissiongroup); } } catch (Exception) { throw new Exception("Lỗi thêm nhóm người dùng"); } }
public void UpdatePermissionGroup(Permissions_Group p) { try { var existingPermission = DB.Permissions_Groups.First(permission => permission.ID == p.ID); existingPermission.GroupID = p.GroupID; existingPermission.PermissionID = p.PermissionID; } catch (Exception) { throw new Exception("Lỗi sửa nhóm quyền"); } }
public void UpdateGroup(UserGroup group) { try { var existingGroup = DB.UserGroups.First(g => g.ID == group.ID); existingGroup.GroupName = group.GroupName; existingGroup.DisplayName = group.DisplayName; existingGroup.Level = group.Level; existingGroup.LastModifiedOnDate = group.LastModifiedOnDate; existingGroup.LastModifiedByUserID = group.LastModifiedByUserID; // delete old permission var oldPermissionList = DB.Permissions_Groups.Where(p => p.GroupID == group.ID); if (oldPermissionList.Any()) { foreach (var permissionsGroup in oldPermissionList) { DeletePermissionGroup(permissionsGroup.ID); } } // update new permission List<Permission> newpermissionList = FindPermissionsByLevel(group.Level.Value).ToList(); var newpermissionGroupIDList = newpermissionList.Select(permission => permission.ID).ToList(); foreach (var permissdionID in newpermissionGroupIDList) { var permissiongroup = new Permissions_Group { GroupID = group.ID, PermissionID = permissdionID }; AddNewPermissionGroup(permissiongroup); } } catch (Exception) { throw new Exception("Lỗi cập nhật nhóm người dùng"); } }
/// <summary> /// Create a new Permissions_Group object. /// </summary> /// <param name="id">Initial value of the ID property.</param> public static Permissions_Group CreatePermissions_Group(global::System.Int32 id) { Permissions_Group permissions_Group = new Permissions_Group(); permissions_Group.ID = id; return permissions_Group; }
/// <summary> /// Deprecated Method for adding a new object to the Permissions_Groups EntitySet. Consider using the .Add method of the associated ObjectSet<T> property instead. /// </summary> public void AddToPermissions_Groups(Permissions_Group permissions_Group) { base.AddObject("Permissions_Groups", permissions_Group); }