Skip to content

Commit 2ef8424

Browse files
author
Bart Koelman
committed
Addressed review feedback
1 parent 723d325 commit 2ef8424

File tree

3 files changed

+13
-13
lines changed

3 files changed

+13
-13
lines changed

src/JsonApiDotNetCore/Middleware/OperationKind.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
namespace JsonApiDotNetCore.Middleware
22
{
33
/// <summary>
4-
/// Lists the functional operation kinds from a resource request or an atomic:operations request.
4+
/// Lists the functional operation kinds of a resource request or an atomic:operations request.
55
/// </summary>
66
public enum OperationKind
77
{

src/JsonApiDotNetCore/Repositories/EntityFrameworkCoreRepository.cs

+4-4
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ public virtual async Task CreateAsync(TResource resourceFromRequest, TResource r
173173
{
174174
object rightResources = relationship.GetValue(resourceFromRequest);
175175

176-
object rightResourcesEdited = await EditRelationshipAsync(resourceForDatabase, relationship, rightResources, OperationKind.CreateResource,
176+
object rightResourcesEdited = await VisitSetRelationshipAsync(resourceForDatabase, relationship, rightResources, OperationKind.CreateResource,
177177
cancellationToken);
178178

179179
await UpdateRelationshipAsync(relationship, resourceForDatabase, rightResourcesEdited, collector, cancellationToken);
@@ -194,7 +194,7 @@ public virtual async Task CreateAsync(TResource resourceFromRequest, TResource r
194194
await _resourceDefinitionAccessor.OnWriteSucceededAsync(resourceForDatabase, OperationKind.CreateResource, cancellationToken);
195195
}
196196

197-
private async Task<object> EditRelationshipAsync(TResource leftResource, RelationshipAttribute relationship, object rightResourceIds,
197+
private async Task<object> VisitSetRelationshipAsync(TResource leftResource, RelationshipAttribute relationship, object rightResourceIds,
198198
OperationKind operationKind, CancellationToken cancellationToken)
199199
{
200200
if (relationship is HasOneAttribute hasOneRelationship)
@@ -241,7 +241,7 @@ public virtual async Task UpdateAsync(TResource resourceFromRequest, TResource r
241241
{
242242
object rightResources = relationship.GetValue(resourceFromRequest);
243243

244-
object rightResourcesEdited = await EditRelationshipAsync(resourceFromDatabase, relationship, rightResources, OperationKind.UpdateResource,
244+
object rightResourcesEdited = await VisitSetRelationshipAsync(resourceFromDatabase, relationship, rightResources, OperationKind.UpdateResource,
245245
cancellationToken);
246246

247247
AssertIsNotClearingRequiredRelationship(relationship, resourceFromDatabase, rightResourcesEdited);
@@ -392,7 +392,7 @@ public virtual async Task SetRelationshipAsync(TResource primaryResource, object
392392
RelationshipAttribute relationship = _targetedFields.Relationships.Single();
393393

394394
object secondaryResourceIdsEdited =
395-
await EditRelationshipAsync(primaryResource, relationship, secondaryResourceIds, OperationKind.SetRelationship, cancellationToken);
395+
await VisitSetRelationshipAsync(primaryResource, relationship, secondaryResourceIds, OperationKind.SetRelationship, cancellationToken);
396396

397397
AssertIsNotClearingRequiredRelationship(relationship, primaryResource, secondaryResourceIdsEdited);
398398

src/JsonApiDotNetCore/Resources/IResourceDefinition.cs

+8-8
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ public interface IResourceDefinition<TResource, TId>
158158
Task OnPrepareWriteAsync(TResource resource, OperationKind operationKind, CancellationToken cancellationToken);
159159

160160
/// <summary>
161-
/// Executes before replacing (overwriting) a to-one relationship.
161+
/// Executes before setting (or clearing) the resource at the right side of a to-one relationship.
162162
/// <para>
163163
/// Implementing this method enables to perform validations and change <paramref name="rightResourceId" />, before the relationship is updated.
164164
/// </para>
@@ -167,10 +167,10 @@ public interface IResourceDefinition<TResource, TId>
167167
/// The original resource retrieved from the underlying data store, that declares <paramref name="hasOneRelationship" />.
168168
/// </param>
169169
/// <param name="hasOneRelationship">
170-
/// The to-one relationship being replaced or cleared.
170+
/// The to-one relationship being set.
171171
/// </param>
172172
/// <param name="rightResourceId">
173-
/// The replacement resource identifier (or <c>null</c> to clear the relationship), coming from the request.
173+
/// The new resource identifier (or <c>null</c> to clear the relationship), coming from the request.
174174
/// </param>
175175
/// <param name="operationKind">
176176
/// Identifies from which endpoint this method was called. Possible values: <see cref="OperationKind.CreateResource" />,
@@ -180,13 +180,13 @@ public interface IResourceDefinition<TResource, TId>
180180
/// Propagates notification that request handling should be canceled.
181181
/// </param>
182182
/// <returns>
183-
/// The replacement resource identifier, or <c>null</c> to clear the relationship.
183+
/// The replacement resource identifier, or <c>null</c> to clear the relationship. Returns <paramref name="rightResourceId" /> by default.
184184
/// </returns>
185185
Task<IIdentifiable> OnSetToOneRelationshipAsync(TResource leftResource, HasOneAttribute hasOneRelationship, IIdentifiable rightResourceId,
186186
OperationKind operationKind, CancellationToken cancellationToken);
187187

188188
/// <summary>
189-
/// Executes before replacing (overwriting) a to-many relationship.
189+
/// Executes before setting the resources at the right side of a to-many relationship. This replaces on existing set.
190190
/// <para>
191191
/// Implementing this method enables to perform validations and make changes to <paramref name="rightResourceIds" />, before the relationship is updated.
192192
/// </para>
@@ -195,7 +195,7 @@ Task<IIdentifiable> OnSetToOneRelationshipAsync(TResource leftResource, HasOneAt
195195
/// The original resource retrieved from the underlying data store, that declares <paramref name="hasManyRelationship" />.
196196
/// </param>
197197
/// <param name="hasManyRelationship">
198-
/// The to-many relationship being replaced.
198+
/// The to-many relationship being set.
199199
/// </param>
200200
/// <param name="rightResourceIds">
201201
/// The set of resource identifiers to replace any existing set with, coming from the request.
@@ -211,7 +211,7 @@ Task OnSetToManyRelationshipAsync(TResource leftResource, HasManyAttribute hasMa
211211
OperationKind operationKind, CancellationToken cancellationToken);
212212

213213
/// <summary>
214-
/// Executes before adding resources to a to-many relationship, as part of a POST relationship request.
214+
/// Executes before adding resources to the right side of a to-many relationship, as part of a POST relationship request.
215215
/// <para>
216216
/// Implementing this method enables to perform validations and make changes to <paramref name="rightResourceIds" />, before the relationship is updated.
217217
/// </para>
@@ -232,7 +232,7 @@ Task OnAddToRelationshipAsync(TId leftResourceId, HasManyAttribute hasManyRelati
232232
CancellationToken cancellationToken);
233233

234234
/// <summary>
235-
/// Executes before removing resources from a to-many relationship, as part of a DELETE relationship request.
235+
/// Executes before removing resources from the right side of a to-many relationship, as part of a DELETE relationship request.
236236
/// <para>
237237
/// Implementing this method enables to perform validations and make changes to <paramref name="rightResourceIds" />, before the relationship is updated.
238238
/// </para>

0 commit comments

Comments
 (0)