mirror of
https://gitlab.com/Kwoth/nadekobot.git
synced 2025-09-11 09:48:26 -04:00
Updated editorconfig to (mostly?) require braces around if/else statements, and applied the new formatting rules
This commit is contained in:
@@ -14,9 +14,7 @@ public class CurrencyService : ICurrencyService, INService
|
||||
public Task<IWallet> GetWalletAsync(ulong userId, CurrencyType type = CurrencyType.Default)
|
||||
{
|
||||
if (type == CurrencyType.Default)
|
||||
{
|
||||
return Task.FromResult<IWallet>(new DefaultWallet(userId, _db.GetDbContext()));
|
||||
}
|
||||
|
||||
throw new ArgumentOutOfRangeException(nameof(type));
|
||||
}
|
||||
@@ -111,10 +109,9 @@ public class CurrencyService : ICurrencyService, INService
|
||||
{
|
||||
await using var fromWallet = await GetWalletAsync(fromId);
|
||||
await using var toWallet = await GetWalletAsync(toId);
|
||||
|
||||
|
||||
var extra = new TxData("gift", fromName, note, fromId);
|
||||
|
||||
|
||||
return await fromWallet.Transfer(amount, toWallet, extra);
|
||||
}
|
||||
|
||||
}
|
@@ -2,5 +2,5 @@
|
||||
|
||||
public enum CurrencyType
|
||||
{
|
||||
Default,
|
||||
Default
|
||||
}
|
@@ -66,9 +66,8 @@ public class DefaultWallet : IWallet
|
||||
{
|
||||
CurrencyAmount = x.CurrencyAmount + amount
|
||||
});
|
||||
|
||||
|
||||
if (changed == 0)
|
||||
{
|
||||
await _ctx.DiscordUser
|
||||
.ToLinqToDBTable()
|
||||
.Value(x => x.UserId, UserId)
|
||||
@@ -76,7 +75,6 @@ public class DefaultWallet : IWallet
|
||||
.Value(x => x.Discriminator, "????")
|
||||
.Value(x => x.CurrencyAmount, amount)
|
||||
.InsertAsync();
|
||||
}
|
||||
|
||||
await tran.CommitAsync();
|
||||
}
|
||||
@@ -88,7 +86,7 @@ public class DefaultWallet : IWallet
|
||||
Note = txData.Note,
|
||||
Type = txData.Type,
|
||||
Extra = txData.Extra,
|
||||
OtherId = txData.OtherId,
|
||||
OtherId = txData.OtherId
|
||||
};
|
||||
|
||||
await _ctx.CreateLinqToDbContext()
|
||||
@@ -100,7 +98,7 @@ public class DefaultWallet : IWallet
|
||||
_ctx.SaveChanges();
|
||||
_ctx.Dispose();
|
||||
}
|
||||
|
||||
|
||||
public async ValueTask DisposeAsync()
|
||||
{
|
||||
await _ctx.SaveChangesAsync();
|
||||
|
@@ -3,11 +3,11 @@ namespace NadekoBot.Services.Currency;
|
||||
public interface IWallet : IDisposable, IAsyncDisposable
|
||||
{
|
||||
public ulong UserId { get; }
|
||||
|
||||
|
||||
public Task<long> GetBalance();
|
||||
public Task<bool> Take(long amount, TxData txData);
|
||||
public Task Add(long amount, TxData txData);
|
||||
|
||||
|
||||
public async Task<bool> Transfer(
|
||||
long amount,
|
||||
IWallet to,
|
||||
|
@@ -1,3 +1,7 @@
|
||||
namespace NadekoBot.Services.Currency;
|
||||
|
||||
public record class TxData(string Type, string Extra, string? Note = "", ulong? OtherId = null);
|
||||
public record class TxData(
|
||||
string Type,
|
||||
string Extra,
|
||||
string? Note = "",
|
||||
ulong? OtherId = null);
|
Reference in New Issue
Block a user