diff options
| author | Roy Ben-Shabat <Roy@Twine-s.com> | 2017-12-19 15:25:33 +0200 |
|---|---|---|
| committer | Roy Ben-Shabat <Roy@Twine-s.com> | 2017-12-19 15:25:33 +0200 |
| commit | cc3bf81fabd005fa74c2b9663589892480f1a6bb (patch) | |
| tree | 37d7a5d21ad32d1aaf3041e3bc08d7d031699325 /Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/ViewModels | |
| parent | 65d969946d89d7572f071c1387d10ecc58e94f61 (diff) | |
| download | Tango-cc3bf81fabd005fa74c2b9663589892480f1a6bb.tar.gz Tango-cc3bf81fabd005fa74c2b9663589892480f1a6bb.zip | |
Added Event Types and Action Types to DB Module !
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.cs | 59 |
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 + }); + } + } + } } } } |
