diff options
| author | Roy Ben Shabat <Roy.mail.net@gmail.com> | 2020-05-10 19:18:31 +0300 |
|---|---|---|
| committer | Roy Ben Shabat <Roy.mail.net@gmail.com> | 2020-05-10 19:18:31 +0300 |
| commit | 9ead141002c63c1a44d7851fa4a4a1902c0bfe89 (patch) | |
| tree | b60a92a9a1ead3b473b63cf049c258386da208c4 /Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Catalogs | |
| parent | ded3658497424534f582b99a8c5702f5c402d0dd (diff) | |
| download | Tango-9ead141002c63c1a44d7851fa4a4a1902c0bfe89.tar.gz Tango-9ead141002c63c1a44d7851fa4a4a1902c0bfe89.zip | |
Fixed issue with MS color catalogs duplicate color codes/names.
Diffstat (limited to 'Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Catalogs')
| -rw-r--r-- | Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Catalogs/ViewModels/MainViewVM.cs | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Catalogs/ViewModels/MainViewVM.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Catalogs/ViewModels/MainViewVM.cs index 406622ee1..8a33f15ef 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Catalogs/ViewModels/MainViewVM.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Catalogs/ViewModels/MainViewVM.cs @@ -318,6 +318,35 @@ namespace Tango.MachineStudio.Catalogs.ViewModels try { IsFree = false; + + //Validate color codes. + var duplicateCodes = ActiveCatalog + .ColorCatalogsGroups + .SelectMany(x => x.ColorCatalogsItems) + .GroupBy(x => x.Code) + .Where(x => x.Count() > 1) + .Select(x => x.First().Code) + .ToList(); + + if (duplicateCodes.Count > 0) + { + throw new InvalidOperationException($"Duplicate color codes found:\n{String.Join(Environment.NewLine, duplicateCodes)}"); + } + + //Validate color names. + var duplicateNames = ActiveCatalog + .ColorCatalogsGroups + .SelectMany(x => x.ColorCatalogsItems) + .GroupBy(x => x.Name) + .Where(x => x.Count() > 1) + .Select(x => x.First().Name) + .ToList(); + + if (duplicateNames.Count > 0) + { + throw new InvalidOperationException($"Duplicate color names found:\n{String.Join(Environment.NewLine, duplicateNames)}"); + } + ActiveCatalog.LastUpdated = DateTime.UtcNow; await _activeCatalogContext.SaveChangesAsync(); |
