forked from ddrilling/AsbCloudServer
CS2-16: Fix критической ошибки при получении двух юзеров с одинаковым Id
This commit is contained in:
parent
b21fe640e0
commit
3a4a27942a
20
AsbCloudApp/Comparators/TelemetryUserDtoComparer.cs
Normal file
20
AsbCloudApp/Comparators/TelemetryUserDtoComparer.cs
Normal file
@ -0,0 +1,20 @@
|
||||
using AsbCloudApp.Data;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace AsbCloudApp.Comparators
|
||||
{
|
||||
public class TelemetryUserDtoComparer : IEqualityComparer<TelemetryUserDto>
|
||||
{
|
||||
public bool Equals(TelemetryUserDto prevUser, TelemetryUserDto nextUser)
|
||||
{
|
||||
if (prevUser is null || nextUser is null)
|
||||
return false;
|
||||
else if (prevUser.Id == nextUser.Id)
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
public int GetHashCode(TelemetryUserDto user) => user.Id.GetHashCode();
|
||||
}
|
||||
}
|
@ -1,5 +1,6 @@
|
||||
using AsbCloudApp.Data;
|
||||
using AsbCloudApp.Services;
|
||||
using AsbCloudApp.Comparators;
|
||||
using AsbCloudDb.Model;
|
||||
using AsbCloudInfrastructure.Services.Cache;
|
||||
using System.Collections.Generic;
|
||||
@ -25,6 +26,8 @@ namespace AsbCloudInfrastructure.Services
|
||||
if (!dtos.Any())
|
||||
return;
|
||||
|
||||
dtos = dtos.Distinct(new TelemetryUserDtoComparer());
|
||||
|
||||
var telemetryId = telemetryService.GetOrCreateTemetryIdByUid(uid);
|
||||
|
||||
var ids = dtos.Select(e => e.Id).ToList();
|
||||
|
Loading…
Reference in New Issue
Block a user