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

View File

@@ -119,9 +119,9 @@ namespace AyaNova.Biz
pai.PartViz = partNames.Where(z => z.Id == pai.PartId).First().Name;
}
//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;
}
@@ -269,13 +269,27 @@ namespace AyaNova.Biz
}
//no duplicate parts
//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))
List<long> SeenPartIds = new List<long>();
for (int i = 0; i < proposedObj.Items.Count; i++)
{
AddError(ApiErrorCode.VALIDATION_FAILED, "Items", "Duplicate parts are not allowed in the items collection");
return;
if (!SeenPartIds.Contains(proposedObj.Items[i].PartId))
{
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
//(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)