コード例 #1
0
ファイル: GroupMap.cs プロジェクト: secc/RockDataImport
        public int? SaveGroup( int groupTypeId, string name, int? parentGroupId = null, bool isSystem = false, int? campusId = null, 
                        string description = null, bool isSecurityRole = false, bool isActive = true, int order = 0, string foreignId = null, 
                        int? groupId = null )
        {
            Group group = null;
            GroupController controller = new GroupController( Service );

            if ( groupId != null )
            {
                group = controller.GetById( (int)groupId );
                if ( groupId == null )
                {
                    return null;
                }
            }
            else
            {
                group = new Group();
            }

            group.IsSystem = isSystem;
            group.ParentGroupId = parentGroupId;
            group.GroupTypeId = groupTypeId;
            group.CampusId = campusId;
            group.Name = name;
            group.Description = description;
            group.IsSecurityRole = isSecurityRole;
            group.IsActive = isActive;
            group.Order = order;
            group.ForeignId = foreignId;

            if ( groupId == null )
            {
                group.CreatedByPersonAliasId = Service.LoggedInPerson.PrimaryAliasId;
                controller.Add( group );
            }
            else
            {
                group.ModifiedByPersonAliasId = Service.LoggedInPerson.PrimaryAliasId;
                controller.Update( group );
            }

            group = controller.GetByGuid( group.Guid );

            return group.Id;
        }