Skip to content

Commit

Permalink
chore: move to json object during settings update
Browse files Browse the repository at this point in the history
  • Loading branch information
DariuszGarbarz committed Aug 23, 2024
1 parent 3ba7dd9 commit 67a043d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
3 changes: 2 additions & 1 deletion BleBoxCommonSimLib/Controllers/SettingsController.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using BleBoxCommonSimLib.Services;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Logging;
using System.Text.Json.Nodes;

namespace BleBoxCommonSimLib.Controllers;

Expand All @@ -21,7 +22,7 @@ public IActionResult SettingsRequested()
}

[HttpPost("api/settings/set")]
public IActionResult SettingsSetRequested(string request)
public IActionResult SettingsSetRequested(JsonObject request)
{
try
{
Expand Down
9 changes: 5 additions & 4 deletions BleBoxCommonSimLib/Services/SettingsService.cs
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
using BleBoxModels.Common.Enums;
using BleBoxModels.Common.Models;
using System.Text.Json.Nodes;

namespace BleBoxCommonSimLib.Services;

public interface ISettingsService
{
Func<SettingsBase, object>? ObtainFullSettings { get; set; }
Func<string, SettingsBase>? UpdateFullSettings { get; set; }
Func<JsonObject, SettingsBase>? UpdateFullSettings { get; set; }

object ReadSettings();
void UpdateSettings(string request);
void UpdateSettings(JsonObject request);
}

public class SettingsService(IDeviceInformationService deviceInformation) : ISettingsService
Expand All @@ -19,7 +20,7 @@ public class SettingsService(IDeviceInformationService deviceInformation) : ISet
private Toggle _statusLedEnabled = Toggle.Enabled;

public Func<SettingsBase, object>? ObtainFullSettings { get; set; }
public Func<string, SettingsBase>? UpdateFullSettings { get; set; }
public Func<JsonObject, SettingsBase>? UpdateFullSettings { get; set; }

public object ReadSettings()
{
Expand All @@ -44,7 +45,7 @@ public object ReadSettings()
return settings;
}

public void UpdateSettings(string request)
public void UpdateSettings(JsonObject request)
{
if (UpdateFullSettings == null)
throw new Exception("Full settings func is null");
Expand Down

0 comments on commit 67a043d

Please sign in to comment.