From c7eeb60ff1108a5aba530f0932a8f89624452420 Mon Sep 17 00:00:00 2001 From: John Cardinal Date: Tue, 16 Mar 2021 22:12:44 +0000 Subject: [PATCH] --- server/AyaNova/biz/PartAssemblyBiz.cs | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/server/AyaNova/biz/PartAssemblyBiz.cs b/server/AyaNova/biz/PartAssemblyBiz.cs index 9eb2a35a..00650abf 100644 --- a/server/AyaNova/biz/PartAssemblyBiz.cs +++ b/server/AyaNova/biz/PartAssemblyBiz.cs @@ -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 SeenPartIds = new List(); + 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)