aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/MachineStudio/Modules
diff options
context:
space:
mode:
authorAvi Levkovich <avi@twine-s.com>2020-05-13 13:27:01 +0300
committerAvi Levkovich <avi@twine-s.com>2020-05-13 13:27:01 +0300
commit15dfc2cdcbc2e518c09c1ee75f32ff149d4a337d (patch)
tree4c0b49773706b85282e6f6b1ec3d2e949d3ca22e /Software/Visual_Studio/MachineStudio/Modules
parent6a49e917c587dcbbfe8175b8dde73840b7d105fc (diff)
parentcd750d626d3780990797faf09446033bbaa4311c (diff)
downloadTango-15dfc2cdcbc2e518c09c1ee75f32ff149d4a337d.tar.gz
Tango-15dfc2cdcbc2e518c09c1ee75f32ff149d4a337d.zip
commit merge
Diffstat (limited to 'Software/Visual_Studio/MachineStudio/Modules')
-rw-r--r--Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Catalogs/ViewModels/MainViewVM.cs29
-rw-r--r--Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.UsersAndRoles/ViewModels/MainViewVM.cs10
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)
{