fix(api): JobControl добавлена выборка сведений о Field для RelationshipFilter. Переписан метод Update
This commit is contained in:
@@ -129,6 +129,7 @@ namespace PARR.API.Controllers.V1
|
|||||||
.ThenInclude(t => t.UnitField)
|
.ThenInclude(t => t.UnitField)
|
||||||
.Include(t => t.UnitFilters)
|
.Include(t => t.UnitFilters)
|
||||||
.ThenInclude(t => t.RelationshipFilters.OrderBy(o => o.UnitField!.AihitName))
|
.ThenInclude(t => t.RelationshipFilters.OrderBy(o => o.UnitField!.AihitName))
|
||||||
|
.ThenInclude(t => t.UnitField)
|
||||||
.FirstOrDefaultAsync(t => t.Id == id);
|
.FirstOrDefaultAsync(t => t.Id == id);
|
||||||
|
|
||||||
if (job == null)
|
if (job == null)
|
||||||
@@ -323,7 +324,38 @@ namespace PARR.API.Controllers.V1
|
|||||||
|
|
||||||
private void UpdateUnitFilters(Job orig, Job mappedRequest)
|
private void UpdateUnitFilters(Job orig, Job mappedRequest)
|
||||||
{
|
{
|
||||||
//Сразу удаляем UnitFilter которых нет
|
orig.UnitFilters.Clear();
|
||||||
|
|
||||||
|
foreach (var mappedUnitFilter in mappedRequest.UnitFilters)
|
||||||
|
{
|
||||||
|
var newUnitFilter = new JobUnitFilter
|
||||||
|
{
|
||||||
|
UnitFilter = mappedUnitFilter.UnitFilter,
|
||||||
|
DateCreated = DateTimeOffset.UtcNow,
|
||||||
|
JobId = orig.Id
|
||||||
|
};
|
||||||
|
|
||||||
|
foreach (var newRequestFieldFilter in mappedUnitFilter.FieldFilters)
|
||||||
|
{
|
||||||
|
var newFieldFilter = CreateFieldFilter(newUnitFilter.Id, newRequestFieldFilter.FieldId, newRequestFieldFilter.ValueMask);
|
||||||
|
|
||||||
|
newUnitFilter.FieldFilters.Add(newFieldFilter);
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach (var newRequestRelationshipFilter in mappedUnitFilter.RelationshipFilters)
|
||||||
|
{
|
||||||
|
var newRelationshipFilter = CreateRelationshipFilter(newRequestRelationshipFilter.FieldId,
|
||||||
|
newRequestRelationshipFilter.IsParent,
|
||||||
|
newRequestRelationshipFilter.IsFullMatch,
|
||||||
|
newRequestRelationshipFilter.IsInverse,
|
||||||
|
newRequestRelationshipFilter.ValueMask);
|
||||||
|
newUnitFilter.RelationshipFilters.Add(newRelationshipFilter);
|
||||||
|
}
|
||||||
|
|
||||||
|
orig.UnitFilters.Add(newUnitFilter);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*//Сразу удаляем UnitFilter которых нет
|
||||||
var toDelete = orig.UnitFilters.Where(t => !mappedRequest.UnitFilters.Any(e => e.Id == t.Id));
|
var toDelete = orig.UnitFilters.Where(t => !mappedRequest.UnitFilters.Any(e => e.Id == t.Id));
|
||||||
foreach (var item in toDelete)
|
foreach (var item in toDelete)
|
||||||
orig.UnitFilters.Remove(item);
|
orig.UnitFilters.Remove(item);
|
||||||
@@ -435,7 +467,7 @@ namespace PARR.API.Controllers.V1
|
|||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
}
|
}*/
|
||||||
}
|
}
|
||||||
|
|
||||||
private static JobRelationshipFilter CreateRelationshipFilter(Guid fieldId, bool isParent, bool isFullMatch, bool isInverse, string valueMask)
|
private static JobRelationshipFilter CreateRelationshipFilter(Guid fieldId, bool isParent, bool isFullMatch, bool isInverse, string valueMask)
|
||||||
|
|||||||
Reference in New Issue
Block a user