EasyAbp/EShop

Duplicate option names in different attribute is not allowed

ericeric284 opened this issue · 1 comments

Our team has added a car renting product, which provides attrubtes like below:

Product: Car renting service

Attibute1: "Pick up location"
Options: "Taipei","Kaohsiung","None"

Attibute2: "Return location"
Options: "Taipei","Kaohsiung","None"

But the creation of product will fail due to the check in the following code, preventing any options with duplicated names,
event if these options are under different attributes.
Is this check necessary? Or are we using it in a wrong way?

var optionNameList = ProductAttributes.SelectMany(a => a.ProductAttributeOptions)
.Select(o => o.DisplayName.Trim()).ToList();
if (optionNameList.Distinct().Count() != optionNameList.Count)
{
yield return new ValidationResult(
"DisplayNames of ProductAttributeOptions should be unique!",
new[] { "ProductAttributeOptions" }
);
}

@ericeric284 - I'm afraid it is a bug. Fixing. 🤣