Merge remote-tracking branch 'origin/master'
This commit is contained in:
commit
22eff77e88
@ -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);
|
||||||
|
Loading…
Reference in New Issue
Block a user