This commit is contained in:
@@ -119,7 +119,7 @@ namespace AyaNova.Biz
|
|||||||
pai.PartViz = partNames.Where(z => z.Id == pai.PartId).First().Name;
|
pai.PartViz = partNames.Where(z => z.Id == pai.PartId).First().Name;
|
||||||
}
|
}
|
||||||
//sort in place by partviz
|
//sort in place by partviz
|
||||||
ret.Items.Sort((lhs,rhs)=> lhs.PartViz.CompareTo(rhs.PartViz));
|
ret.Items.Sort((lhs, rhs) => lhs.PartViz.CompareTo(rhs.PartViz));
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
@@ -269,13 +269,27 @@ namespace AyaNova.Biz
|
|||||||
}
|
}
|
||||||
|
|
||||||
//no duplicate parts
|
//no duplicate parts
|
||||||
//this would be caused by an API user not our UI so no need to translation
|
List<long> SeenPartIds = new List<long>();
|
||||||
if (proposedObj.Items.GroupBy(z => z.PartId).Any(g => g.Count() > 1))
|
for (int i = 0; i < proposedObj.Items.Count; i++)
|
||||||
{
|
{
|
||||||
AddError(ApiErrorCode.VALIDATION_FAILED, "Items", "Duplicate parts are not allowed in the items collection");
|
if (!SeenPartIds.Contains(proposedObj.Items[i].PartId))
|
||||||
return;
|
{
|
||||||
|
SeenPartIds.Add(proposedObj.Items[i].PartId);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
AddError(ApiErrorCode.VALIDATION_NOT_UNIQUE, $"Items[{i}].PartId");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// //this would be caused by an API user not our UI so no need to translation
|
||||||
|
// if (proposedObj.Items.GroupBy(z => z.PartId).Any(g => g.Count() > 1))
|
||||||
|
// {
|
||||||
|
// ApiErrorCode.VALIDATION_NOT_UNIQUE
|
||||||
|
// AddError(ApiErrorCode.VALIDATION_FAILED, "generalerror", "Duplicate parts are not allowed in the items collection");
|
||||||
|
// return;
|
||||||
|
// }
|
||||||
|
|
||||||
//Make sure there are no < 1 quantities and if there are make them 1 rather than reporting a broken rule
|
//Make sure there are no < 1 quantities and if there are make them 1 rather than reporting a broken rule
|
||||||
//(decided this based on UI and likelyhood etc it woudl be hard to show this as a biz rule with the simple UI for it)
|
//(decided this based on UI and likelyhood etc it woudl be hard to show this as a biz rule with the simple UI for it)
|
||||||
foreach (var pai in proposedObj.Items)
|
foreach (var pai in proposedObj.Items)
|
||||||
|
|||||||
Reference in New Issue
Block a user