Updated editorconfig to (mostly?) require braces around if/else statements, and applied the new formatting rules

This commit is contained in:
Kwoth
2022-02-02 01:44:45 +01:00
parent b22cd5a81e
commit ffa2c3f119
202 changed files with 2108 additions and 920 deletions

View File

@@ -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);
}
}

View File

@@ -2,5 +2,5 @@
public enum CurrencyType
{
Default,
Default
}

View File

@@ -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();

View File

@@ -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,

View File

@@ -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);