Update to test play count support on older versions
This commit is contained in:
parent
7edcd07723
commit
e159a427a0
@ -1,4 +1,5 @@
|
||||
using Domain.Enums;
|
||||
using Domain.Entities;
|
||||
using Domain.Enums;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace Application.Game.Card.Write;
|
||||
@ -29,6 +30,21 @@ public class WriteBDataCommandHandler : RequestHandlerBase<WriteCardBDataCommand
|
||||
data.CardId = request.CardId;
|
||||
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);
|
||||
|
||||
return new ServiceResult<string>(request.Data);
|
||||
|
Loading…
Reference in New Issue
Block a user