Skip to content

Commit 8a2a149

Browse files
.
1 parent 241aa87 commit 8a2a149

File tree

2 files changed

+69
-46
lines changed

2 files changed

+69
-46
lines changed

roles/lib/files/FWO.Services/ModellingConnectionHandler.cs

Lines changed: 27 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1019,18 +1019,39 @@ public bool CalcVisibility()
10191019
return true;
10201020
}
10211021

1022-
public bool NetworkAreaUseForbidden(ModellingDnDContainer modellingContainer)
1022+
public bool NetworkAreaUseAllowed(ModellingDnDContainer modellingContainer)
10231023
{
1024-
if (modellingContainer.AreaElements.Count == 0)
1024+
if (ActConn.IsInterface)
10251025
{
1026+
DisplayMessageInUi(default, "Add Network Area", "Interfaces must not contain network areas", true);
10261027
return false;
10271028
}
1029+
bool hasCommonNetworkAreas = HasCommonNetworkAreas(modellingContainer.AreaElements);
10281030

1029-
if ((!ActConn.IsCommonService && !ActConn.IsInterface) || ActConn.IsCommonService)
1031+
//Uncommon network areas should only be selectable under “Common Services”
1032+
if (!hasCommonNetworkAreas && ActConn.IsCommonService)
10301033
{
1031-
//Is Connection
1032-
//NAs should be selectable under Modelling -> “Connections” + “Common Services”
1033-
return false;
1034+
return true;
1035+
}
1036+
//Common network areas may be selected in “Common Services” + “Connections”
1037+
if (hasCommonNetworkAreas && ( ActConn.IsCommonService || ( !ActConn.IsInterface && !ActConn.IsCommonService ) ))
1038+
{
1039+
return true;
1040+
}
1041+
1042+
DisplayMessageInUi(default, "Add Network Area", "The reason why it's not allowed", true);
1043+
return false;
1044+
}
1045+
private bool HasCommonNetworkAreas(List<ModellingNetworkArea> networkAreas)
1046+
{
1047+
CommonAreaConfigItems.Add(new() { AreaId = 1 });
1048+
1049+
foreach (ModellingNetworkArea area in networkAreas)
1050+
{
1051+
if (CommonAreaConfigItems.Any(_ => _.AreaId == area.Id))
1052+
{
1053+
return true;
1054+
}
10341055
}
10351056

10361057
return false;

0 commit comments

Comments
 (0)