diff options
| author | Avi Levkovich <avi@twine-s.com> | 2020-05-13 13:27:01 +0300 |
|---|---|---|
| committer | Avi Levkovich <avi@twine-s.com> | 2020-05-13 13:27:01 +0300 |
| commit | 15dfc2cdcbc2e518c09c1ee75f32ff149d4a337d (patch) | |
| tree | 4c0b49773706b85282e6f6b1ec3d2e949d3ca22e /Software/Visual_Studio/MachineStudio/Modules | |
| parent | 6a49e917c587dcbbfe8175b8dde73840b7d105fc (diff) | |
| parent | cd750d626d3780990797faf09446033bbaa4311c (diff) | |
| download | Tango-15dfc2cdcbc2e518c09c1ee75f32ff149d4a337d.tar.gz Tango-15dfc2cdcbc2e518c09c1ee75f32ff149d4a337d.zip | |
commit merge
Diffstat (limited to 'Software/Visual_Studio/MachineStudio/Modules')
2 files changed, 39 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(); diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.UsersAndRoles/ViewModels/MainViewVM.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.UsersAndRoles/ViewModels/MainViewVM.cs index d20b74c77..16395d6bc 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.UsersAndRoles/ViewModels/MainViewVM.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.UsersAndRoles/ViewModels/MainViewVM.cs @@ -274,6 +274,11 @@ namespace Tango.MachineStudio.UsersAndRoles.ViewModels try { ManagedUser.Validate(_userContext); + + if (ManagedUser.Roles.GroupBy(x => x.RoleEnum).Any(x => x.Count() > 1)) + { + throw new InvalidOperationException("Cannot save user with duplicate roles."); + } } catch (Exception ex) { @@ -296,6 +301,11 @@ namespace Tango.MachineStudio.UsersAndRoles.ViewModels try { ManagedUser.Validate(_userContext); + + if (ManagedUser.Roles.GroupBy(x => x.RoleEnum).Any(x => x.Count() > 1)) + { + throw new InvalidOperationException("Cannot save user with duplicate roles."); + } } catch (Exception ex) { |
