Skip to content

Commit 298f8cd

Browse files
Ticket #25 : Set SchemaId and RepresentationId
1 parent 55cee7d commit 298f8cd

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

src/Scim/SimpleIdServer.Scim.Persistence.EF/EFSCIMRepresentationCommandRepository.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ public bool Add(SCIMRepresentation data)
2929
Version = data.Version,
3030
ResourceType = data.ResourceType,
3131
Id = data.Id,
32-
Attributes = data.Attributes.Select(a => a.ToModel()).ToList(),
32+
Attributes = data.Attributes.Select(a => a.ToModel(data.Id)).ToList(),
3333
Schemas = data.Schemas.Select(s => new SCIMRepresentationSchemaModel
3434
{
3535
SCIMRepresentationId = data.Id,

src/Scim/SimpleIdServer.Scim.Persistence.EF/Extensions/MappingExtensions.cs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ namespace SimpleIdServer.Scim.Persistence.EF.Extensions
1010
{
1111
public static class MappingExtensions
1212
{
13-
public static SCIMRepresentationAttributeModel ToModel(this SCIMRepresentationAttribute a)
13+
public static SCIMRepresentationAttributeModel ToModel(this SCIMRepresentationAttribute a, string representationId)
1414
{
1515
var values = new List<SCIMRepresentationAttributeValueModel>();
1616
values.AddRange(a.ValuesBoolean.Select(b => new SCIMRepresentationAttributeValueModel
@@ -42,6 +42,7 @@ public static SCIMRepresentationAttributeModel ToModel(this SCIMRepresentationAt
4242
{
4343
Id = a.Id,
4444
Values = values,
45+
RepresentationId = representationId,
4546
ParentId = a.Parent == null ? null : a.Parent.Id,
4647
SchemaAttributeId = a.SchemaAttribute.Id,
4748
Children = new List<SCIMRepresentationAttributeModel>()
@@ -51,7 +52,7 @@ public static SCIMRepresentationAttributeModel ToModel(this SCIMRepresentationAt
5152
{
5253
foreach (var r in a.Values)
5354
{
54-
result.Children.Add(ToModel(r));
55+
result.Children.Add(ToModel(r, representationId));
5556
}
5657
}
5758

@@ -73,16 +74,17 @@ public static SCIMSchemaModel ToModel(this SCIMSchema schema)
7374
Required = s.Required,
7475
Schema = s.Schema
7576
}).ToList(),
76-
Attributes = schema.Attributes.Select(s => ToModel(s)).ToList()
77+
Attributes = schema.Attributes.Select(s => ToModel(s, schema.Id)).ToList()
7778
};
7879
return result;
7980
}
8081

81-
public static SCIMSchemaAttributeModel ToModel(this SCIMSchemaAttribute schemaAttribute)
82+
public static SCIMSchemaAttributeModel ToModel(this SCIMSchemaAttribute schemaAttribute, string schemaId)
8283
{
8384
var result = new SCIMSchemaAttributeModel
8485
{
8586
Id = schemaAttribute.Id,
87+
SchemaId = schemaId,
8688
CanonicalValues = schemaAttribute.CanonicalValues.ToList(),
8789
CaseExact = schemaAttribute.CaseExact,
8890
DefaultValueInt = schemaAttribute.DefaultValueInt.ToList(),
@@ -103,7 +105,7 @@ public static SCIMSchemaAttributeModel ToModel(this SCIMSchemaAttribute schemaAt
103105
{
104106
foreach (var subAttr in schemaAttribute.SubAttributes.ToList())
105107
{
106-
result.SubAttributes.Add(ToModel(subAttr));
108+
result.SubAttributes.Add(ToModel(subAttr, schemaId));
107109
}
108110
}
109111

0 commit comments

Comments
 (0)