public OrganizationalStructure AddSubUnit(SimpleLookup unitType, string unitName, bool canAddSubUnit) { if (!CanAddSubUnit) { throw new ArgumentOutOfRangeException(); } return(new OrganizationalStructure(Guid.NewGuid()) { OrganizationId = this.OrganizationId, Code = this.Code + "." + ShortGuid.GenerateCode(2), Name = unitName, ParentId = this.Id, StructureType = unitType, CanAddSubUnit = canAddSubUnit }); }