public UserPositionsVM(UserVM user, AccessType access) : base(access) { UnitOfWork = new SoheilEdmContext(); CurrentUser = user; UserDataService = new UserDataService(UnitOfWork); PositionDataService = new PositionDataService(UnitOfWork); AccessRuleDataService = new AccessRuleDataService(UnitOfWork); UserDataService.PositionAdded += OnPositionAdded; UserDataService.PositionRemoved += OnPositionRemoved; var selectedVms = new ObservableCollection<UserPositionVM>(); foreach (var userPosition in UserDataService.GetPositions(user.Id)) { selectedVms.Add(new UserPositionVM(userPosition, Access, RelationDirection.Straight)); } SelectedItems = new ListCollectionView(selectedVms); var allVms = new ObservableCollection<PositionVM>(); foreach (var position in PositionDataService.GetActives(SoheilEntityType.Users, CurrentUser.Id)) { allVms.Add(new PositionVM(position, Access, PositionDataService)); } AllItems = new ListCollectionView(allVms); //AllItems = new ListCollectionView(PositionDataService.GetActives()); IncludeCommand = new Command(Include, CanInclude); ExcludeCommand = new Command(Exclude, CanExclude); }
public AccessRulePositionsVM(AccessRuleVM accessRule, AccessType access) : base(access) { UnitOfWork = new SoheilEdmContext(); CurrentAccessRule = accessRule; AccessRuleDataService = new AccessRuleDataService(UnitOfWork); AccessRuleDataService.PositionAdded += OnPositionAdded; AccessRuleDataService.PositionRemoved += OnPositionRemoved; PositionDataService = new PositionDataService(UnitOfWork); var selectedVms = new ObservableCollection<PositionAccessRuleVM>(); foreach (var accessRulePosition in AccessRuleDataService.GetPositions(accessRule.Id)) { selectedVms.Add(new PositionAccessRuleVM(accessRulePosition, Access, RelationDirection.Reverse)); } SelectedItems = new ListCollectionView(selectedVms); var allVms = new ObservableCollection<PositionVM>(); foreach (var position in PositionDataService.GetActives()) { allVms.Add(new PositionVM(position, Access,PositionDataService)); } AllItems = new ListCollectionView(allVms); IncludeCommand = new Command(Include,CanInclude); ExcludeCommand = new Command(Exclude,CanExclude); }
public AccessRuleUsersVM(AccessRuleVM accessRule, AccessType access) : base(access) { UnitOfWork = new SoheilEdmContext(); CurrentAccessRule = accessRule; AccessRuleDataService = new AccessRuleDataService(UnitOfWork); AccessRuleDataService.UserAdded += OnUserAdded; AccessRuleDataService.UserRemoved += OnUserRemoved; UserDataService = new UserDataService(UnitOfWork); var selectedVms = new ObservableCollection<UserAccessRuleVM>(); foreach (var accessRuleUser in AccessRuleDataService.GetUsers(accessRule.Id)) { selectedVms.Add(new UserAccessRuleVM(accessRuleUser, Access, RelationDirection.Reverse)); } SelectedItems = new ListCollectionView(selectedVms); var allVms = new ObservableCollection<UserVM>(); foreach (var user in UserDataService.GetActives()) { allVms.Add(new UserVM(user, Access, UserDataService)); } AllItems = new ListCollectionView(allVms); IncludeCommand = new Command(Include,CanInclude); ExcludeCommand = new Command(Exclude, CanExclude); }
public MainWindow() { _accessRuleDataService = new AccessRuleDataService(); _userDataService = new UserDataService(); var culture = CultureInfo.GetCultureInfo("fa-IR"); Dispatcher.Thread.CurrentCulture = culture; Dispatcher.Thread.CurrentUICulture = culture; LocalizationManager.UpdateValues(); InitializeComponent(); AccessList = new List<Tuple<string, AccessType>>(); LoginCommand = new Command(Login); _newTabNumber = 1; // temp //Login(null); //SetValue(LoginProperty, true); //. Closing += (s, e) => Soheil.Core.PP.PPItemManager.Abort(); if (Environment.UserName == "Bizhan" || Environment.UserName == "Bizz") { //SingularList = new Core.ViewModels.PP.PPTableVm(AccessType.Full); //chrometabs.AddTab(CreateSingularTab(SoheilEntityType.ProductPlanTable), true); } }
/// <summary> /// Initializes a new instance of the <see cref="ProductVM"/> class from the model. /// </summary> /// <param name="dataService"></param> /// <param name="entity">The model.</param> /// <param name="access"></param> public AccessRuleVM(AccessRuleDataService dataService, AccessRule entity, AccessType access) : base(access) { InitializeData(dataService); _model = entity; ParentId = entity.Parent == null? 0: entity.Parent.Id; Title = Name; foreach (var child in entity.Children) { ChildNodes.Add(new AccessRuleVM(dataService, child, Access)); } }
private void InitializeData() { UnitOfWork = new SoheilEdmContext(); AccessRuleDataService = new AccessRuleDataService(UnitOfWork); AccessRuleDataService.AccessRuleAdded += OnAccessRuleAdded; AddCommand = new Command(Add, CanAdd);RefreshCommand = new Command(CreateItems); AddGroupCommand = new Command(Add, CanAddGroup); ViewCommand = new Command(View, CanView); //var viewModels = AccessRuleDataService.GetAll(); CreateItems(null); //CurrentNode = (ISplitNodeContent) CurrentContent; }
public PositionAccessNodeVM(int accessRuleId, int positionId, AccessRuleDataService accessRuleDataService, PositionAccessRuleDataService positionAccessRuleDataService, AccessType access) : base(access) { var accessRule = accessRuleDataService.GetSingle(accessRuleId); Title = Common.Properties.Resources.ResourceManager.GetString(accessRule.Name); Id = accessRule.Id; ParentId =accessRule.Parent != null? accessRule.Parent.Id : -1; foreach (var child in accessRule.Children) { ChildNodes.Add(new PositionAccessNodeVM(child.Id,positionId,accessRuleDataService, positionAccessRuleDataService, Access)); } var positionAccessRule = positionAccessRuleDataService.GetSingle(positionId, accessRuleId); if (positionAccessRule != null) { if (positionAccessRule.Type != null) PositionAccess = (AccessType) positionAccessRule.Type; } }
public UserAccessRulesVM(UserVM user, AccessType access):base(access) { UnitOfWork = new SoheilEdmContext(); CurrentUser = user; UserDataService = new UserDataService(UnitOfWork); UserDataService.AccessRuleChanged += OnAccessRuleChanged; AccessRuleDataService = new AccessRuleDataService(UnitOfWork); UserAccessRuleDataService = new UserAccessRuleDataService(UnitOfWork); PositionAccessRuleDataService = new PositionAccessRuleDataService(UnitOfWork); RootNode = new UserAccessNodeVM(Access) { Title = string.Empty, Id = -1, ParentId = -2 }; var selectedVms = new ObservableCollection<UserAccessNodeVM>(); var ruleAccessList = AccessRuleDataService.GetPositionsAccessOfUser(user.Id); foreach (var accessRule in AccessRuleDataService.GetActives()) { selectedVms.Add(new UserAccessNodeVM(accessRule.Id, user.Id, AccessRuleDataService, UserAccessRuleDataService, ruleAccessList, Access)); } var allVms = new ObservableCollection<AccessRuleVM>(); foreach (var accessRule in AccessRuleDataService.GetActives()) { allVms.Add(new AccessRuleVM(AccessRuleDataService, accessRule, Access)); } AllItems = new ListCollectionView(allVms); IncludeCommand = new Command(Include, CanInclude); ExcludeTreeCommand = new Command(ExcludeTree, CanExcludeTree); foreach (UserAccessNodeVM item in selectedVms) { if (item.ParentId == RootNode.Id) { RootNode.ChildNodes.Add(item); break; } } CurrentNode = RootNode; }
public UserAccessNodeVM(int accessRuleId, int userId, AccessRuleDataService accessRuleDataService, UserAccessRuleDataService userAccessRuleDataService, List<Tuple<int, AccessType>> ruleAccessList, AccessType access) : base(access) { var accessRule = accessRuleDataService.GetSingle(accessRuleId); Title = Common.Properties.Resources.ResourceManager.GetString(accessRule.Name); Id = accessRule.Id; ParentId = accessRule.Parent != null ? accessRule.Parent.Id : -1; foreach (var child in accessRule.Children) { ChildNodes.Add(new UserAccessNodeVM(child.Id, userId, accessRuleDataService, userAccessRuleDataService, ruleAccessList, Access)); } var userAccessRule = userAccessRuleDataService.GetSingle(userId, accessRuleId); if (userAccessRule != null) { if (userAccessRule.Type != null) UserAccess = (AccessType)userAccessRule.Type; } if(!ruleAccessList.Any()) return; foreach (Tuple<int, AccessType> tuple in ruleAccessList.Where(item => item.Item1 == accessRuleId)) { PositionAccess |= tuple.Item2; } }
private void InitializeData(AccessRuleDataService dataService) { AccessRuleDataService = dataService; SaveCommand = new Command(Save, CanSave); ChildNodes = new ObservableCollection<IEntityNode>(); }
/// <summary> /// Initializes a new instance of the <see cref="ProductGroupVM"/> class initialized with default values. /// </summary> public AccessRuleVM(AccessType access, AccessRuleDataService dataService):base(access) { InitializeData(dataService); _model = new AccessRule(); }
public static AccessRule CreateNew(AccessRuleDataService dataService) { int id = dataService.AddModel(new AccessRule { Name = "جدید", Code = string.Empty }); return dataService.GetSingle(id); }