This commit is contained in:
2021-03-16 22:12:44 +00:00
parent f6109b96da
commit c7eeb60ff1

View File

@@ -269,12 +269,26 @@ 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)