mirror of
https://github.com/DrMboga/WotBlitzStatisticsBlazor.git
synced 2026-10-30 13:50:04 +01:00
Nullable refernce types refactoring
This commit is contained in:
1 parent
e5c90e03d3
commit
e12734981b
85 files changed
+509
-351
No files matched your search
+16
-5
@@ -1,12 +1,13 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using AutoMapper;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using WotBlitzStatisticsPro.DataAccess.Model.Accounts;
|
||||
using WotBlitzStatisticsPro.Logic.AccountInformationPipeline.OperationContext;
|
||||
using WotBlitzStatisticsPro.Logic.Pipeline;
|
||||
using WotBlitzStatisticsPro.WgApiClient;
|
||||
using WotBlitzStatisticsPro.WgApiClient.Model;
|
||||
|
||||
namespace WotBlitzStatisticsPro.Logic.AccountInformationPipeline.Operations
|
||||
{
|
||||
@@ -14,26 +15,36 @@ namespace WotBlitzStatisticsPro.Logic.AccountInformationPipeline.Operations
|
||||
{
|
||||
private readonly IWargamingTanksApiClient _wargamingApi;
|
||||
private readonly IMapper _mapper;
|
||||
private readonly ILogger<GetTanksInfoOperation> _logger;
|
||||
|
||||
public GetTanksInfoOperation(
|
||||
IWargamingTanksApiClient wargamingApi,
|
||||
IMapper mapper)
|
||||
IMapper mapper,
|
||||
ILogger<GetTanksInfoOperation> logger)
|
||||
{
|
||||
_wargamingApi = wargamingApi;
|
||||
_mapper = mapper;
|
||||
_logger = logger;
|
||||
}
|
||||
|
||||
public async Task Invoke(IOperationContext context, Func<IOperationContext, Task> next)
|
||||
public async Task Invoke(IOperationContext context, Func<IOperationContext, Task>? next)
|
||||
{
|
||||
var contextData = context.Get<AccountInformationPipelineContextData>();
|
||||
|
||||
var tanksInfo = await
|
||||
_wargamingApi.GetPlayerAccountTanksInfo(context.Request.AccountId, context.Request.RealmType, context.Request.RequestLanguage);
|
||||
|
||||
if (tanksInfo == null)
|
||||
{
|
||||
_logger.LogInformation(
|
||||
$"Tanks not found for AccountId {context.Request.AccountId} and {context.Request.RealmType} realm");
|
||||
return;
|
||||
}
|
||||
|
||||
contextData.Tanks = new List<TankInfo>();
|
||||
contextData.TanksHistory = new Dictionary<long, TankInfoHistory>();
|
||||
|
||||
tanksInfo.ForEach(tank =>
|
||||
tanksInfo.OrderByDescending(t => t.LastBattleTime).ToList().ForEach(tank =>
|
||||
{
|
||||
var tankInfo = new TankInfo(tank.AccountId, tank.TankId);
|
||||
_mapper.Map(tank, tankInfo);
|
||||
@@ -43,7 +54,7 @@ namespace WotBlitzStatisticsPro.Logic.AccountInformationPipeline.Operations
|
||||
contextData.TanksHistory[stat.TankId] = stat;
|
||||
});
|
||||
|
||||
await next.Invoke(context);
|
||||
if (next != null) await next.Invoke(context);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user