Changed the default way to modify values in store. Added basic validation to stores. Using interfaces to DI store objects.

This commit is contained in:
Tom
2025-01-16 19:49:02 +00:00
parent b00c72ec2a
commit ee3f128a9f
24 changed files with 173 additions and 61 deletions

View File

@@ -1,3 +1,4 @@
using HermesSocketLibrary.Requests.Messages;
using HermesSocketServer.Models;
using ILogger = Serilog.ILogger;
@@ -25,16 +26,16 @@ namespace HermesSocketServer.Requests
return Task.FromResult(RequestResult.Failed("Order must be an integer."));
bool state = data["state"].ToString()?.ToLower() == "true";
bool result = channel.Redemptions.Modify(id, r =>
{
if (r.UserId != channel.Id)
return;
Redemption redemption = new Redemption() {
Id = id,
UserId = channel.Id,
RedemptionId = redemptionId,
ActionName = actionName,
Order = order,
State = state,
};
r.RedemptionId = redemptionId;
r.ActionName = actionName;
r.Order = order;
r.State = state;
});
bool result = channel.Redemptions.Modify(id, redemption);
var r = channel.Redemptions.Get(id);
if (result)