partial void DeleteUserGroup(UserGroup instance);
partial void InsertUserGroup(UserGroup instance);
partial void UpdateUserGroup(UserGroup instance);
/// <summary> /// Find a user group, or add it if it doesn't exist. Return the id of the user group. /// </summary> /// <param name="UserGroupName">The user group name to find or add.</param> /// <returns>The id of the user group that was found or added.</returns> /// <remarks>All user group interaction is done this way to remove any dependencies on pre-populated tables.</remarks> public int FindOrAddGroup( string UserGroupName ) { using( FAutoScopedLogTimer LogTimer = new FAutoScopedLogTimer( this.GetType().ToString() + "(GroupName=" + UserGroupName + ")" ) ) { int UserGroupNameId = 0; try { IQueryable<int> UserGroups = ( from UserGroupDetail in Context.UserGroups where UserGroupDetail.Name.ToLower() == UserGroupName.ToLower() select UserGroupDetail.Id ); // If there is no existing group, add a new one if( UserGroups.Count() == 0 ) { UserGroup NewUserGroup = new UserGroup(); NewUserGroup.Name = UserGroupName; Context.UserGroups.InsertOnSubmit( NewUserGroup ); Context.SubmitChanges(); UserGroupNameId = NewUserGroup.Id; } else { UserGroupNameId = UserGroups.First(); } } catch( Exception Ex ) { Debug.WriteLine( "FindOrAddUserGroup: " + Ex.ToString() ); } return UserGroupNameId; } }