From c77ff0390f499bb919e2ff0a4d5e89e77cfc5efa Mon Sep 17 00:00:00 2001 From: Joao Rua Date: Fri, 19 Apr 2024 14:34:51 +0100 Subject: [PATCH] partially refactored code --- COMET.Web.Common/Extensions/SessionServiceExtensions.cs | 2 +- .../Components/Publications/PublicationsViewModel.cs | 2 +- .../Components/BookEditor/BookEditorBodyViewModel.cs | 4 ++-- .../DeletableDataItemTable/DeletableDataItemTableViewModel.cs | 2 +- .../DeprecatableDataItemTableViewModel.cs | 2 +- .../FileStore/FileHandler/FileHandlerViewModel.cs | 4 ++-- .../FileStore/FolderHandler/FolderHandlerViewModel.cs | 2 +- .../Components/ModelEditor/ElementDefinitionTableViewModel.cs | 2 +- .../DomainsOfExpertise/DomainsOfExpertiseTableViewModel.cs | 2 +- .../EngineeringModels/ActiveDomainsTableViewModel.cs | 2 +- .../EngineeringModels/ParticipantsTableViewModel.cs | 2 +- .../UserManagement/UserManagementTableViewModel.cs | 2 +- .../Viewer/PropertiesPanel/PropertiesComponentViewModel.cs | 2 +- 13 files changed, 15 insertions(+), 15 deletions(-) diff --git a/COMET.Web.Common/Extensions/SessionServiceExtensions.cs b/COMET.Web.Common/Extensions/SessionServiceExtensions.cs index 040cc87e..b8807482 100644 --- a/COMET.Web.Common/Extensions/SessionServiceExtensions.cs +++ b/COMET.Web.Common/Extensions/SessionServiceExtensions.cs @@ -81,7 +81,7 @@ public static async Task 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]); } } } diff --git a/COMET.Web.Common/ViewModels/Components/Publications/PublicationsViewModel.cs b/COMET.Web.Common/ViewModels/Components/Publications/PublicationsViewModel.cs index a7af6926..24417eca 100644 --- a/COMET.Web.Common/ViewModels/Components/Publications/PublicationsViewModel.cs +++ b/COMET.Web.Common/ViewModels/Components/Publications/PublicationsViewModel.cs @@ -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); } diff --git a/COMETwebapp/ViewModels/Components/BookEditor/BookEditorBodyViewModel.cs b/COMETwebapp/ViewModels/Components/BookEditor/BookEditorBodyViewModel.cs index 2d16fec8..e1b84f6a 100644 --- a/COMETwebapp/ViewModels/Components/BookEditor/BookEditorBodyViewModel.cs +++ b/COMETwebapp/ViewModels/Components/BookEditor/BookEditorBodyViewModel.cs @@ -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; @@ -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; } diff --git a/COMETwebapp/ViewModels/Components/Common/DeletableDataItemTable/DeletableDataItemTableViewModel.cs b/COMETwebapp/ViewModels/Components/Common/DeletableDataItemTable/DeletableDataItemTableViewModel.cs index 6b0fbd21..30e92869 100644 --- a/COMETwebapp/ViewModels/Components/Common/DeletableDataItemTable/DeletableDataItemTableViewModel.cs +++ b/COMETwebapp/ViewModels/Components/Common/DeletableDataItemTable/DeletableDataItemTableViewModel.cs @@ -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) diff --git a/COMETwebapp/ViewModels/Components/Common/DeprecatableDataItemTable/DeprecatableDataItemTableViewModel.cs b/COMETwebapp/ViewModels/Components/Common/DeprecatableDataItemTable/DeprecatableDataItemTableViewModel.cs index 324933ac..2930febd 100644 --- a/COMETwebapp/ViewModels/Components/Common/DeprecatableDataItemTable/DeprecatableDataItemTableViewModel.cs +++ b/COMETwebapp/ViewModels/Components/Common/DeprecatableDataItemTable/DeprecatableDataItemTableViewModel.cs @@ -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) diff --git a/COMETwebapp/ViewModels/Components/EngineeringModel/FileStore/FileHandler/FileHandlerViewModel.cs b/COMETwebapp/ViewModels/Components/EngineeringModel/FileStore/FileHandler/FileHandlerViewModel.cs index 510a2824..15e05a39 100644 --- a/COMETwebapp/ViewModels/Components/EngineeringModel/FileStore/FileHandler/FileHandlerViewModel.cs +++ b/COMETwebapp/ViewModels/Components/EngineeringModel/FileStore/FileHandler/FileHandlerViewModel.cs @@ -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); @@ -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(); } diff --git a/COMETwebapp/ViewModels/Components/EngineeringModel/FileStore/FolderHandler/FolderHandlerViewModel.cs b/COMETwebapp/ViewModels/Components/EngineeringModel/FileStore/FolderHandler/FolderHandlerViewModel.cs index 4b029404..279f0bfe 100644 --- a/COMETwebapp/ViewModels/Components/EngineeringModel/FileStore/FolderHandler/FolderHandlerViewModel.cs +++ b/COMETwebapp/ViewModels/Components/EngineeringModel/FileStore/FolderHandler/FolderHandlerViewModel.cs @@ -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; diff --git a/COMETwebapp/ViewModels/Components/ModelEditor/ElementDefinitionTableViewModel.cs b/COMETwebapp/ViewModels/Components/ModelEditor/ElementDefinitionTableViewModel.cs index 56d794ea..9320d4aa 100644 --- a/COMETwebapp/ViewModels/Components/ModelEditor/ElementDefinitionTableViewModel.cs +++ b/COMETwebapp/ViewModels/Components/ModelEditor/ElementDefinitionTableViewModel.cs @@ -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) diff --git a/COMETwebapp/ViewModels/Components/SiteDirectory/DomainsOfExpertise/DomainsOfExpertiseTableViewModel.cs b/COMETwebapp/ViewModels/Components/SiteDirectory/DomainsOfExpertise/DomainsOfExpertiseTableViewModel.cs index 2bf1e4cd..4c9a7b3f 100644 --- a/COMETwebapp/ViewModels/Components/SiteDirectory/DomainsOfExpertise/DomainsOfExpertiseTableViewModel.cs +++ b/COMETwebapp/ViewModels/Components/SiteDirectory/DomainsOfExpertise/DomainsOfExpertiseTableViewModel.cs @@ -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(); } } diff --git a/COMETwebapp/ViewModels/Components/SiteDirectory/EngineeringModels/ActiveDomainsTableViewModel.cs b/COMETwebapp/ViewModels/Components/SiteDirectory/EngineeringModels/ActiveDomainsTableViewModel.cs index 991e357f..ab5f58aa 100644 --- a/COMETwebapp/ViewModels/Components/SiteDirectory/EngineeringModels/ActiveDomainsTableViewModel.cs +++ b/COMETwebapp/ViewModels/Components/SiteDirectory/EngineeringModels/ActiveDomainsTableViewModel.cs @@ -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) diff --git a/COMETwebapp/ViewModels/Components/SiteDirectory/EngineeringModels/ParticipantsTableViewModel.cs b/COMETwebapp/ViewModels/Components/SiteDirectory/EngineeringModels/ParticipantsTableViewModel.cs index 8b5a3884..f9052c72 100644 --- a/COMETwebapp/ViewModels/Components/SiteDirectory/EngineeringModels/ParticipantsTableViewModel.cs +++ b/COMETwebapp/ViewModels/Components/SiteDirectory/EngineeringModels/ParticipantsTableViewModel.cs @@ -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) diff --git a/COMETwebapp/ViewModels/Components/SiteDirectory/UserManagement/UserManagementTableViewModel.cs b/COMETwebapp/ViewModels/Components/SiteDirectory/UserManagement/UserManagementTableViewModel.cs index e3602052..26d6585f 100644 --- a/COMETwebapp/ViewModels/Components/SiteDirectory/UserManagement/UserManagementTableViewModel.cs +++ b/COMETwebapp/ViewModels/Components/SiteDirectory/UserManagement/UserManagementTableViewModel.cs @@ -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(); } diff --git a/COMETwebapp/ViewModels/Components/Viewer/PropertiesPanel/PropertiesComponentViewModel.cs b/COMETwebapp/ViewModels/Components/Viewer/PropertiesPanel/PropertiesComponentViewModel.cs index 6caa27ad..202fff4f 100644 --- a/COMETwebapp/ViewModels/Components/Viewer/PropertiesPanel/PropertiesComponentViewModel.cs +++ b/COMETwebapp/ViewModels/Components/Viewer/PropertiesPanel/PropertiesComponentViewModel.cs @@ -176,7 +176,7 @@ public void OnSubmit() var clonedParameterValueSet = parameterValueSetBase.Clone(false); var valueSetNewValue = valueSet.ActualValue; clonedParameterValueSet.Manual = valueSetNewValue; - this.SessionService.UpdateThings(parameterValueSetBase.GetContainerOfType(), new List { clonedParameterValueSet }); + this.SessionService.CreateOrUpdateThings(parameterValueSetBase.GetContainerOfType(), new List { clonedParameterValueSet }); } }