From 8e04fa1a01d30d8165569fee0c0d4b23f76b0f70 Mon Sep 17 00:00:00 2001 From: SpoinkyNL Date: Mon, 18 Nov 2019 21:46:01 +0100 Subject: [PATCH] Fix build --- src/Artemis.Core/Models/Profile/Profile.cs | 25 +++++++++++++------ src/Artemis.Core/Models/Surface/Surface.cs | 4 +-- .../Services/Storage/ProfileService.cs | 14 ++++++++--- .../ProfileEditor/ProfileEditorViewModel.cs | 2 +- 4 files changed, 31 insertions(+), 14 deletions(-) diff --git a/src/Artemis.Core/Models/Profile/Profile.cs b/src/Artemis.Core/Models/Profile/Profile.cs index b7d871f5c..51a3a4e30 100644 --- a/src/Artemis.Core/Models/Profile/Profile.cs +++ b/src/Artemis.Core/Models/Profile/Profile.cs @@ -11,8 +11,22 @@ namespace Artemis.Core.Models.Profile { public class Profile : IProfileElement { + internal Profile(PluginInfo pluginInfo, string name) + { + ProfileEntity = new ProfileEntity {RootFolder = new FolderEntity()}; + Guid = System.Guid.NewGuid().ToString(); + + PluginInfo = pluginInfo; + Name = name; + + Children = new List(); + } + internal Profile(PluginInfo pluginInfo, ProfileEntity profileEntity, IPluginService pluginService) { + ProfileEntity = profileEntity; + Guid = profileEntity.Guid; + PluginInfo = pluginInfo; Name = profileEntity.Name; @@ -20,16 +34,11 @@ namespace Artemis.Core.Models.Profile Children = new List {Folder.FromFolderEntity(this, profileEntity.RootFolder, pluginService)}; } - internal Profile(PluginInfo pluginInfo, string name) - { - PluginInfo = pluginInfo; - Name = name; - - Children = new List(); - } - public PluginInfo PluginInfo { get; } public bool IsActivated { get; private set; } + + internal ProfileEntity ProfileEntity { get; set; } + internal string Guid { get; set; } public int Order { get; set; } public string Name { get; set; } public List Children { get; set; } diff --git a/src/Artemis.Core/Models/Surface/Surface.cs b/src/Artemis.Core/Models/Surface/Surface.cs index 9054aba71..19a14327c 100644 --- a/src/Artemis.Core/Models/Surface/Surface.cs +++ b/src/Artemis.Core/Models/Surface/Surface.cs @@ -23,11 +23,11 @@ namespace Artemis.Core.Models.Surface internal Surface(RGBSurface rgbSurface, SurfaceEntity surfaceEntity, double scale) { - RgbSurface = rgbSurface; SurfaceEntity = surfaceEntity; - Scale = scale; Guid = surfaceEntity.Guid; + RgbSurface = rgbSurface; + Scale = scale; Name = surfaceEntity.Name; IsActive = surfaceEntity.IsActive; Devices = new List(); diff --git a/src/Artemis.Core/Services/Storage/ProfileService.cs b/src/Artemis.Core/Services/Storage/ProfileService.cs index 89de07f78..f5dab97d8 100644 --- a/src/Artemis.Core/Services/Storage/ProfileService.cs +++ b/src/Artemis.Core/Services/Storage/ProfileService.cs @@ -27,7 +27,7 @@ namespace Artemis.Core.Services.Storage var profileEntities = await _profileRepository.GetByPluginGuidAsync(module.PluginInfo.Guid); var profiles = new List(); foreach (var profileEntity in profileEntities) - profiles.Add(Profile.FromProfileEntity(module.PluginInfo, profileEntity, _pluginService)); + profiles.Add(new Profile(module.PluginInfo, profileEntity, _pluginService)); return profiles; } @@ -38,13 +38,21 @@ namespace Artemis.Core.Services.Storage if (profileEntity == null) return null; - return Profile.FromProfileEntity(module.PluginInfo, profileEntity, _pluginService); + return new Profile(module.PluginInfo, profileEntity, _pluginService); + } + + public async Task CreateProfile(ProfileModule module, string name) + { + var profile = new Profile(module.PluginInfo, name); + await SaveProfile(profile); + + return profile; } public async Task SaveProfile(Profile profile) { // Find a matching profile entity to update - + var existing = await _profileRepository.GetByGuidAsync(profile.) // If not found, create a new one await _profileRepository.SaveAsync(); diff --git a/src/Artemis.UI/Screens/Module/ProfileEditor/ProfileEditorViewModel.cs b/src/Artemis.UI/Screens/Module/ProfileEditor/ProfileEditorViewModel.cs index 5f5a49369..3b73b18d2 100644 --- a/src/Artemis.UI/Screens/Module/ProfileEditor/ProfileEditorViewModel.cs +++ b/src/Artemis.UI/Screens/Module/ProfileEditor/ProfileEditorViewModel.cs @@ -74,7 +74,7 @@ namespace Artemis.UI.Screens.Module.ProfileEditor if (!profiles.Any()) { - var profile = new Profile(); + var profile = new Profile(Module.PluginInfo, "Default"); } } }