1
0
mirror of synced 2024-11-24 06:20:12 +01:00

Merge remote-tracking branch 'origin/master'

This commit is contained in:
asesidaa 2023-11-05 18:42:51 +08:00
commit 22eff77e88

View File

@ -1,4 +1,5 @@
using Domain.Enums; using Domain.Entities;
using Domain.Enums;
using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging;
namespace Application.Game.Card.Write; namespace Application.Game.Card.Write;
@ -29,6 +30,21 @@ public class WriteBDataCommandHandler : RequestHandlerBase<WriteCardBDataCommand
data.CardId = request.CardId; data.CardId = request.CardId;
await CardDbContext.CardBdata.Upsert(data).RunAsync(cancellationToken); await CardDbContext.CardBdata.Upsert(data).RunAsync(cancellationToken);
var cardPlayCount = await CardDbContext.CardPlayCounts
.FirstOrDefaultAsync(count => count.CardId == request.CardId, cancellationToken);
if (cardPlayCount is null)
{
cardPlayCount = new CardPlayCount
{
CardId = request.CardId,
PlayCount = 0,
LastPlayedTime = DateTime.Now
};
}
cardPlayCount.PlayCount++;
cardPlayCount.LastPlayedTime = DateTime.Now;
await CardDbContext.CardPlayCounts.Upsert(cardPlayCount).RunAsync(cancellationToken);
await CardDbContext.SaveChangesAsync(cancellationToken); await CardDbContext.SaveChangesAsync(cancellationToken);
return new ServiceResult<string>(request.Data); return new ServiceResult<string>(request.Data);