Skip to content

Commit

Permalink
partially refactored code
Browse files Browse the repository at this point in the history
  • Loading branch information
joao4all committed Apr 19, 2024
1 parent f81d7ce commit c77ff03
Show file tree
Hide file tree
Showing 13 changed files with 15 additions and 15 deletions.
2 changes: 1 addition & 1 deletion COMET.Web.Common/Extensions/SessionServiceExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ public static async Task<Result> AddParameter(this ISessionService sessionServic
var clone = elementDefinition.Clone(false);
clone.Parameter.Add(parameter);

return await sessionService.CreateThing(clone, parameter);
return await sessionService.CreateOrUpdateThings(clone, [parameter]);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ public async Task ExecutePublish()

publication.PublishedParameter = parametersToPublish;

await this.SessionService.CreateThing(iteration, publication);
await this.SessionService.CreateOrUpdateThings(iteration, [publication]);

this.RemovePublishedData(rowsToPublish, parametersToPublish);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,7 @@ public async Task OnCreateThing()
return;
}

await this.SessionService.CreateThing(thingContainer.Clone(false), this.ThingToCreate);
await this.SessionService.CreateOrUpdateThings(thingContainer.Clone(false), [this.ThingToCreate]);

this.ThingToCreate = null;
this.EditorPopupViewModel.IsVisible = false;
Expand Down Expand Up @@ -405,7 +405,7 @@ public async Task OnDeleteThing()
var thingContainer = this.ThingToDelete.Container;
var thingContainerClone = thingContainer.Clone(false);

await this.SessionService.DeleteThing(thingContainerClone, this.ThingToDelete.Clone(false));
await this.SessionService.DeleteThings(thingContainerClone, [this.ThingToDelete.Clone(false)]);

this.ThingToDelete = null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ public async Task DeleteThing()

try
{
await this.SessionService.DeleteThing(clonedContainer, this.Thing);
await this.SessionService.DeleteThings(clonedContainer, [this.Thing]);
await this.SessionService.RefreshSession();
}
catch (Exception exception)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ public async Task DeprecateOrUnDeprecateThing()

try
{
await this.SessionService.UpdateThings(siteDirectoryClone, clonedThing);
await this.SessionService.CreateOrUpdateThings(siteDirectoryClone, [clonedThing]);
await this.SessionService.RefreshSession();
}
catch (Exception exception)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ public async Task CreateOrEditFile(bool shouldCreate)

thingsToUpdate.Add(this.File);

await this.SessionService.UpdateThings(fileStoreClone, thingsToUpdate, newFileRevisions.Select(x => x.LocalPath));
await this.SessionService.CreateOrUpdateThings(fileStoreClone, thingsToUpdate, newFileRevisions.Select(x => x.LocalPath).ToList());
await this.SessionService.RefreshSession();

this.logger.LogInformation("File with iid {iid} updated successfully", this.File.Iid);
Expand All @@ -221,7 +221,7 @@ public async Task DeleteFile()
{
var clonedContainer = this.File.Container.Clone(false);

await this.SessionService.DeleteThing(clonedContainer, this.File);
await this.SessionService.DeleteThings(clonedContainer, [this.File]);
await this.SessionService.RefreshSession();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ public async Task MoveFolder(Folder folder, Folder targetFolder)
var folderClone = folder.Clone(true);
folderClone.ContainingFolder = targetFolder;

await this.SessionService.UpdateThings(this.CurrentFileStore.Clone(true), folderClone);
await this.SessionService.CreateOrUpdateThings(this.CurrentFileStore.Clone(true), [folderClone]);
await this.SessionService.RefreshSession();

this.IsLoading = false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ public async Task AddingElementDefinition()

try
{
await this.sessionService.CreateThings(clonedIteration, thingsToCreate);
await this.sessionService.CreateOrUpdateThings(clonedIteration, thingsToCreate);
this.IsOnCreationMode = false;
}
catch (Exception exception)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public async Task CreateOrEditDomainOfExpertise(bool shouldCreate)
}

thingsToCreate.Add(this.Thing);
await this.SessionService.UpdateThings(siteDirectoryClone, thingsToCreate);
await this.SessionService.CreateOrUpdateThings(siteDirectoryClone, thingsToCreate);
await this.SessionService.RefreshSession();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ public async Task EditActiveDomains()
var modelClone = this.CurrentModel.Clone(false);
modelClone.ActiveDomain = this.SelectedDomainsOfExpertise.ToList();

await this.SessionService.UpdateThing(modelClone.Container.Clone(false), modelClone);
await this.SessionService.CreateOrUpdateThings(modelClone.Container.Clone(false), [modelClone]);
await this.SessionService.RefreshSession();
}
catch (Exception ex)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ public async Task CreateOrEditParticipant(bool shouldCreate)
}

thingsToCreate.Add(this.Thing);
await this.SessionService.UpdateThings(modelClone, thingsToCreate);
await this.SessionService.CreateOrUpdateThings(modelClone, thingsToCreate);
await this.SessionService.RefreshSession();
}
catch (Exception ex)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ public async Task ActivateOrDeactivatePerson(GridDataColumnCellDisplayTemplateCo
var clonedPerson = personToUpdate.Clone(false);
clonedPerson.IsActive = value;

await this.SessionService.UpdateThings(siteDirectoryClone, clonedPerson);
await this.SessionService.CreateOrUpdateThings(siteDirectoryClone, [clonedPerson]);
await this.SessionService.RefreshSession();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ public void OnSubmit()
var clonedParameterValueSet = parameterValueSetBase.Clone(false);
var valueSetNewValue = valueSet.ActualValue;
clonedParameterValueSet.Manual = valueSetNewValue;
this.SessionService.UpdateThings(parameterValueSetBase.GetContainerOfType<Iteration>(), new List<Thing> { clonedParameterValueSet });
this.SessionService.CreateOrUpdateThings(parameterValueSetBase.GetContainerOfType<Iteration>(), new List<Thing> { clonedParameterValueSet });
}
}

Expand Down

0 comments on commit c77ff03

Please sign in to comment.