Test Pinned via API ||
This commit is contained in:
@ -9,20 +9,54 @@ public class PinRepository : IPinRepository
|
||||
|
||||
private readonly string _MockRoot;
|
||||
private readonly Serilog.ILogger _Log;
|
||||
private readonly Dictionary<string, Dictionary<long, HeaderCommon>> _RdsToHeaderCommonCollection;
|
||||
|
||||
public PinRepository(string mockRoot)
|
||||
{
|
||||
_MockRoot = mockRoot;
|
||||
_RdsToHeaderCommonCollection = new();
|
||||
_Log = Serilog.Log.ForContext<PinRepository>();
|
||||
}
|
||||
|
||||
Result<Pinned[]> IPinRepository.GetPinnedTable(IMetrologyRepository metrologyRepository, int id, string? bioRad, string? cde)
|
||||
void IPinRepository.SetPinnedTable(HeaderCommon headerCommon)
|
||||
{
|
||||
Dictionary<long, HeaderCommon>? toolIdToHeader;
|
||||
if (!string.IsNullOrEmpty(headerCommon.RDS))
|
||||
{
|
||||
if (!_RdsToHeaderCommonCollection.TryGetValue(headerCommon.RDS, out toolIdToHeader))
|
||||
{
|
||||
_RdsToHeaderCommonCollection.Add(headerCommon.RDS, new());
|
||||
if (!_RdsToHeaderCommonCollection.TryGetValue(headerCommon.RDS, out toolIdToHeader))
|
||||
throw new Exception();
|
||||
}
|
||||
if (toolIdToHeader.ContainsKey(headerCommon.ToolTypeID))
|
||||
toolIdToHeader[headerCommon.ToolTypeID] = headerCommon;
|
||||
else
|
||||
toolIdToHeader.Add(headerCommon.ToolTypeID, headerCommon);
|
||||
}
|
||||
}
|
||||
|
||||
Result<Pinned[]> IPinRepository.GetPinnedTable(IMetrologyRepository metrologyRepository, int id, string? rds, string? bioRad, string? cde)
|
||||
{
|
||||
Result<Pinned[]>? r;
|
||||
HeaderCommon? cdeHeader = cde is null ? null : JsonSerializer.Deserialize<HeaderCommon>(cde);
|
||||
long cdeId = cdeHeader is null ? (long)IPinRepository.ToolId.CDE : cdeHeader.ToolTypeID;
|
||||
HeaderCommon? bioRadHeader = bioRad is null ? null : JsonSerializer.Deserialize<HeaderCommon>(bioRad);
|
||||
long bioRadId = bioRadHeader is null ? (long)IPinRepository.ToolId.BioRad : bioRadHeader.ToolTypeID;
|
||||
if (!string.IsNullOrEmpty(rds) && (cdeHeader is null || bioRadHeader is null))
|
||||
{
|
||||
Dictionary<long, HeaderCommon>? toolIdToHeader;
|
||||
if (!_RdsToHeaderCommonCollection.TryGetValue(rds, out toolIdToHeader))
|
||||
{
|
||||
_RdsToHeaderCommonCollection.Add(rds, new());
|
||||
if (!_RdsToHeaderCommonCollection.TryGetValue(rds, out toolIdToHeader))
|
||||
throw new Exception();
|
||||
}
|
||||
if (cdeHeader is null && toolIdToHeader.ContainsKey(cdeId))
|
||||
cdeHeader = toolIdToHeader[cdeId];
|
||||
if (bioRadHeader is null && toolIdToHeader.ContainsKey(bioRadId))
|
||||
bioRadHeader = toolIdToHeader[bioRadId];
|
||||
}
|
||||
if (cdeId != id && bioRadId != id)
|
||||
r = new() { Results = Array.Empty<Pinned>(), TotalRows = 0 };
|
||||
else
|
||||
|
Reference in New Issue
Block a user