aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/DBViewModels/UsersViewVM.cs
diff options
context:
space:
mode:
authorRoy Ben-Shabat <Roy@Twine-s.com>2017-12-13 15:19:55 +0200
committerRoy Ben-Shabat <Roy@Twine-s.com>2017-12-13 15:19:55 +0200
commit2a51f05523c1397b77eca5e5188520919205638c (patch)
treeedc40c2ca201be6e881ea6746469fb5cb412e8bc /Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/DBViewModels/UsersViewVM.cs
parent2c376ac3ae651dd6c6592cc4cbf72768dc97a93d (diff)
downloadTango-2a51f05523c1397b77eca5e5188520919205638c.tar.gz
Tango-2a51f05523c1397b77eca5e5188520919205638c.zip
Successfully separated Machine Studio to modules...
Diffstat (limited to 'Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/DBViewModels/UsersViewVM.cs')
-rw-r--r--Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/DBViewModels/UsersViewVM.cs75
1 files changed, 0 insertions, 75 deletions
diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/DBViewModels/UsersViewVM.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/DBViewModels/UsersViewVM.cs
deleted file mode 100644
index 2bf34ce7a..000000000
--- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/DBViewModels/UsersViewVM.cs
+++ /dev/null
@@ -1,75 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Collections.ObjectModel;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-using Tango.DAL.Observables;
-
-namespace Tango.MachineStudio.UI.ViewModels.DBViewModels
-{
- public class UsersViewVM : DbTableViewModel<User>
- {
- private ObservableCollection<MultiComboVM<Role>> _selectedRoles;
- public ObservableCollection<MultiComboVM<Role>> SelectedRoles
- {
- get { return _selectedRoles; }
- set { _selectedRoles = value; RaisePropertyChangedAuto(); }
- }
-
- public UsersViewVM() : base()
- {
- SelectedRoles = new ObservableCollection<MultiComboVM<Role>>();
- }
-
- protected override void OnEdit()
- {
- SelectedRoles = Adapter.Roles.Select(x => new MultiComboVM<Role>(x, () => RaisePropertyChanged(nameof(SelectedRoles)))).ToObservableCollection();
-
- foreach (var role in SelectedRoles)
- {
- if (SelectedEntity.UsersRoles.ToList().Exists(x => x.Role == role.Entity && !x.Deleted))
- {
- role.IsSelected = true;
- }
- }
-
- base.OnEdit();
- }
-
- protected override void OnAdd()
- {
- SelectedRoles = Adapter.Roles.Select(x => new MultiComboVM<Role>(x, () => RaisePropertyChanged(nameof(SelectedRoles)))).ToObservableCollection();
-
- base.OnAdd();
- }
-
- protected override void OnBeforeEntitySave(DialogOpenMode mode, User user)
- {
- base.OnBeforeEntitySave(mode, user);
-
- foreach (var role in SelectedRoles)
- {
- var userRole = user.UsersRoles.SingleOrDefault(x => x.Role == role.Entity);
-
- if (userRole != null)
- {
- userRole.Deleted = !role.IsSelected;
- }
- else
- {
- if (role.IsSelected)
- {
- user.UsersRoles.Add(new UsersRole()
- {
- Role = role.Entity,
- User = user,
- RoleGuid = role.Entity.Guid,
- UserGuid = user.Guid
- });
- }
- }
- }
- }
- }
-}