aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/ViewModels
diff options
context:
space:
mode:
Diffstat (limited to 'Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/ViewModels')
-rw-r--r--Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/ViewModels/ActionTypesViewVM.cs (renamed from Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/ViewModels/ActionsTypesViewVM.cs)4
-rw-r--r--Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/ViewModels/EventTypesViewVM.cs59
2 files changed, 61 insertions, 2 deletions
diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/ViewModels/ActionsTypesViewVM.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/ViewModels/ActionTypesViewVM.cs
index c627ffbc4..fe9ebda26 100644
--- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/ViewModels/ActionsTypesViewVM.cs
+++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/ViewModels/ActionTypesViewVM.cs
@@ -8,9 +8,9 @@ using Tango.MachineStudio.Common.Notifications;
namespace Tango.MachineStudio.DB.ViewModels
{
- public class ActionsTypesViewVM : DbTableViewModel<ActionType>
+ public class ActionTypesViewVM : DbTableViewModel<ActionType>
{
- public ActionsTypesViewVM(INotificationProvider notification) : base(notification)
+ public ActionTypesViewVM(INotificationProvider notification) : base(notification)
{
}
diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/ViewModels/EventTypesViewVM.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/ViewModels/EventTypesViewVM.cs
index 442eac908..69e3c9ff6 100644
--- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/ViewModels/EventTypesViewVM.cs
+++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/ViewModels/EventTypesViewVM.cs
@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
+using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
@@ -12,6 +13,64 @@ namespace Tango.MachineStudio.DB.ViewModels
{
public EventTypesViewVM(INotificationProvider notification) : base(notification)
{
+ SelectedActions = new ObservableCollection<MultiComboVM<ActionType>>();
+ }
+
+ private ObservableCollection<MultiComboVM<ActionType>> _selectedActions;
+ public ObservableCollection<MultiComboVM<ActionType>> SelectedActions
+ {
+ get { return _selectedActions; }
+ set { _selectedActions = value; RaisePropertyChangedAuto(); }
+ }
+
+ protected override void OnEdit()
+ {
+ SelectedActions = Adapter.ActionTypes.Select(x => new MultiComboVM<ActionType>(x, () => RaisePropertyChanged(nameof(SelectedActions)))).ToObservableCollection();
+
+ foreach (var actionType in SelectedActions)
+ {
+ if (SelectedEntity.EventTypesActions.ToList().Exists(x => x.ActionTypes == actionType.Entity && !x.Deleted))
+ {
+ actionType.IsSelected = true;
+ }
+ }
+
+ base.OnEdit();
+ }
+
+ protected override void OnAdd()
+ {
+ SelectedActions = Adapter.ActionTypes.Select(x => new MultiComboVM<ActionType>(x, () => RaisePropertyChanged(nameof(SelectedActions)))).ToObservableCollection();
+
+ base.OnAdd();
+ }
+
+ protected override void OnBeforeEntitySave(DialogOpenMode mode, EventType eventType)
+ {
+ base.OnBeforeEntitySave(mode, eventType);
+
+ foreach (var actionType in SelectedActions)
+ {
+ var userRole = eventType.EventTypesActions.SingleOrDefault(x => x.ActionTypes == actionType.Entity);
+
+ if (userRole != null)
+ {
+ userRole.Deleted = !actionType.IsSelected;
+ }
+ else
+ {
+ if (actionType.IsSelected)
+ {
+ eventType.EventTypesActions.Add(new EventTypesAction()
+ {
+ ActionTypes = actionType.Entity,
+ EventTypes = eventType,
+ ActionTypeGuid = actionType.Entity.Guid,
+ EventTypeGuid = eventType.Guid
+ });
+ }
+ }
+ }
}
}
}