diff --git a/Application/Game/Card/Write/WriteCardBDataCommand.cs b/Application/Game/Card/Write/WriteCardBDataCommand.cs index bee48b9..1d59915 100644 --- a/Application/Game/Card/Write/WriteCardBDataCommand.cs +++ b/Application/Game/Card/Write/WriteCardBDataCommand.cs @@ -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 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(request.Data);