Skip to content

Commit c2a8fe8

Browse files
committed
Changed return type for ISqlTopicRepository.Save() to void
Previously, the `ISqlTopicRepository.Save()` method—and, thus, all of its implementations—expected a return type of `int`, representing the `Topic.Id`. This is most valuable when saving a new topic, which wouldn't have had an `Id` previously assigned. In most cases, however, this is never expected or needed. And, in the few cases where it is, it can easily be retrieved from `Topic.Id` instead—which is always available, since it's a required parameter of `Save()`.
1 parent 9197965 commit c2a8fe8

6 files changed

Lines changed: 12 additions & 21 deletions

File tree

OnTopic.Data.Caching/CachedTopicRepository.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ public CachedTopicRepository(ITopicRepository dataProvider) : base() {
135135
| METHOD: SAVE
136136
\-------------------------------------------------------------------------------------------------------------------------*/
137137
/// <inheritdoc />
138-
public override int Save(Topic topic, bool isRecursive = false) =>
138+
public override void Save(Topic topic, bool isRecursive = false) =>
139139
_dataProvider.Save(topic, isRecursive);
140140

141141
/*==========================================================================================================================

OnTopic.Data.Sql/SqlTopicRepository.cs

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,7 @@ public override Topic Load(int topicId, DateTime version) {
245245
| METHOD: SAVE
246246
\-------------------------------------------------------------------------------------------------------------------------*/
247247
/// <inheritdoc />
248-
public override int Save([NotNull]Topic topic, bool isRecursive = false) {
248+
public override void Save([NotNull]Topic topic, bool isRecursive = false) {
249249

250250
/*------------------------------------------------------------------------------------------------------------------------
251251
| Establish dependencies
@@ -260,7 +260,7 @@ public override int Save([NotNull]Topic topic, bool isRecursive = false) {
260260
/*------------------------------------------------------------------------------------------------------------------------
261261
| Handle first pass
262262
\-----------------------------------------------------------------------------------------------------------------------*/
263-
var topicId = Save(topic, isRecursive, connection, unresolvedTopics, version);
263+
Save(topic, isRecursive, connection, unresolvedTopics, version);
264264

265265
/*------------------------------------------------------------------------------------------------------------------------
266266
| Attempt to resolve outstanding relationships
@@ -270,10 +270,9 @@ public override int Save([NotNull]Topic topic, bool isRecursive = false) {
270270
}
271271

272272
/*------------------------------------------------------------------------------------------------------------------------
273-
| Return value
273+
| Close shared connection
274274
\-----------------------------------------------------------------------------------------------------------------------*/
275275
connection.Close();
276-
return topicId;
277276

278277
}
279278

@@ -301,7 +300,7 @@ public override int Save([NotNull]Topic topic, bool isRecursive = false) {
301300
/// <param name="isRecursive">Determines whether or not to recursively save <see cref="Topic.Children"/>.</param>
302301
/// <param name="connection">The open <see cref="SqlConnection"/> to use for executing <see cref="SqlCommand"/>s.</param>
303302
/// <param name="unresolvedRelationships">A list of <see cref="Topic"/>s with unresolved topic references.</param>
304-
private int Save(
303+
private void Save(
305304
[NotNull]Topic topic,
306305
bool isRecursive,
307306
SqlConnection connection,
@@ -351,7 +350,7 @@ SqlDateTime version
351350
\-----------------------------------------------------------------------------------------------------------------------*/
352351
if (!isDirty) {
353352
recurse();
354-
return topic.Id;
353+
return;
355354
}
356355

357356
/*------------------------------------------------------------------------------------------------------------------------
@@ -490,13 +489,12 @@ SqlDateTime version
490489
}
491490

492491
/*------------------------------------------------------------------------------------------------------------------------
493-
| Return value
492+
| Recuse over any children
494493
\-----------------------------------------------------------------------------------------------------------------------*/
495494
recurse();
496-
return topic.Id;
497495

498496
/*------------------------------------------------------------------------------------------------------------------------
499-
| Recurse
497+
| Function: Recurse
500498
\-----------------------------------------------------------------------------------------------------------------------*/
501499
void recurse() {
502500
if (isRecursive) {

OnTopic.TestDoubles/DummyTopicRepository.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ public DummyTopicRepository() : base() { }
4242
| METHOD: SAVE
4343
\-------------------------------------------------------------------------------------------------------------------------*/
4444
/// <inheritdoc />
45-
public override int Save(Topic topic, bool isRecursive = false) => throw new NotImplementedException();
45+
public override void Save(Topic topic, bool isRecursive = false) => throw new NotImplementedException();
4646

4747
/*==========================================================================================================================
4848
| METHOD: MOVE

OnTopic.TestDoubles/StubTopicRepository.cs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ public StubTopicRepository() : base() {
105105
| METHOD: SAVE
106106
\-------------------------------------------------------------------------------------------------------------------------*/
107107
/// <inheritdoc />
108-
public override int Save(Topic topic, bool isRecursive = false) {
108+
public override void Save(Topic topic, bool isRecursive = false) {
109109

110110
/*------------------------------------------------------------------------------------------------------------------------
111111
| Call base method - will trigger any events associated with the save
@@ -128,11 +128,6 @@ public override int Save(Topic topic, bool isRecursive = false) {
128128
}
129129
}
130130

131-
/*------------------------------------------------------------------------------------------------------------------------
132-
| Return identity
133-
\-----------------------------------------------------------------------------------------------------------------------*/
134-
return topic.Id;
135-
136131
}
137132

138133
/*==========================================================================================================================

OnTopic/Repositories/ITopicRepository.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,12 +103,11 @@ public interface ITopicRepository {
103103
/// <param name="isRecursive">
104104
/// Boolean indicator nothing whether to recurse through the topic's descendants and save them as well.
105105
/// </param>
106-
/// <returns>The integer return value from the execution of the <c>topics_UpdateTopic</c> stored procedure.</returns>
107106
/// <requires description="The topic to save must be specified." exception="T:System.ArgumentNullException">
108107
/// topic is not null
109108
/// </requires>
110109
/// <exception cref="ArgumentNullException">topic</exception>
111-
int Save(Topic topic, bool isRecursive = false);
110+
void Save(Topic topic, bool isRecursive = false);
112111

113112
/*==========================================================================================================================
114113
| METHOD: MOVE

OnTopic/Repositories/TopicRepositoryBase.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -299,7 +299,7 @@ public virtual void Rollback([ValidatedNotNull]Topic topic, DateTime version) {
299299
| METHOD: SAVE
300300
\-------------------------------------------------------------------------------------------------------------------------*/
301301
/// <inheritdoc />
302-
public virtual int Save([ValidatedNotNull]Topic topic, bool isRecursive = false) {
302+
public virtual void Save([ValidatedNotNull]Topic topic, bool isRecursive = false) {
303303

304304
/*------------------------------------------------------------------------------------------------------------------------
305305
| Validate parameters
@@ -386,7 +386,6 @@ _contentTypeDescriptors is not null &&
386386
| Reset original key
387387
\-----------------------------------------------------------------------------------------------------------------------*/
388388
topic.OriginalKey = null;
389-
return -1;
390389

391390
}
392391

0 commit comments

Comments
 (0)