Files
WotBlitzStatisticsBlazor/WotBlitzStatisticsPro.Logic/AccountInformationPipeline/Operations/CheckLAstBattleDateOperation.cs
T

28 lines
1.1 KiB
C#
Raw Normal View History

2020-11-01 14:10:57 +01:00
using System;
using System.Threading.Tasks;
2020-11-05 14:57:40 +01:00
using Microsoft.Extensions.Logging;
2020-11-01 14:10:57 +01:00
using WotBlitzStatisticsPro.Logic.Pipeline;
namespace WotBlitzStatisticsPro.Logic.AccountInformationPipeline.Operations
{
2020-11-05 14:57:40 +01:00
public class CheckLastBattleDateOperation : IOperation<AccountInformationPipelineContext>
2020-11-01 14:10:57 +01:00
{
2020-11-05 14:57:40 +01:00
private readonly ILogger<CheckLastBattleDateOperation> _logger;
public CheckLastBattleDateOperation(ILogger<CheckLastBattleDateOperation> logger)
{
_logger = logger;
}
2020-11-01 14:10:57 +01:00
public Task Invoke(AccountInformationPipelineContext context, Func<AccountInformationPipelineContext, Task> next)
{
if (context.DbAccountInfo == null ||
2020-11-06 19:23:20 +01:00
context.DbAccountInfo.LastBattleTime < context.AccountInfo.LastBattleTime)
2020-11-01 14:10:57 +01:00
{
return next.Invoke(context);
}
2020-11-05 14:57:40 +01:00
_logger.LogInformation($"Exiting without saving. Db LastBattleTime: {context.DbAccountInfo.LastBattleTime}, WG LastBattleTime: {context.AccountInfo.LastBattleTime}");
2020-11-01 14:10:57 +01:00
return Task.CompletedTask;
}
}
}