Example #1
0
        void OnCommit()
        {
            DbConversation.UsingTransaction(() =>
            {
                if (EditMode == EditMode.Add)
                {
                    DbConversation.Insert(CurrentEdit);
                    EventAggregator.GetEvent <UserAddedEvent>().Publish(CurrentEdit);
                }
                else
                {
                    foreach (var user in _editedUsers)
                    {
                        if (CurrentEdit.Name != null)
                        {
                            user.Name = CurrentEdit.Name;
                        }
                        if (CurrentEdit.UserRole != null)
                        {
                            user.UserRole = CurrentEdit.UserRole;
                        }
                        EventAggregator.GetEvent <UserChangedEvent>().Publish(user);
                    }
                }
            });

            if (_navigationJournal != null)
            {
                _navigationJournal.GoBack();
            }
        }
Example #2
0
        public void OnNavigatedTo(NavigationContext navigationContext)
        {
            var userRoles = GetUserRoles(navigationContext).ToList();

            if (userRoles.Any())
            {
                DbConversation.UsingTransaction(() =>
                {
                    EditMode  = EditMode.Edit;
                    var first = true;
                    foreach (var userRoleId in userRoles)
                    {
                        var userRole = DbConversation.GetById <UserRole>(userRoleId);
                        Name         = EditItemsViewModel.GetTargetValue(first, CurrentEdit.Name, userRole.Name, null);
                        _editedUserRoles.Add(userRole);
                        first = false;
                    }
                });
            }
            _navigationJournal = navigationContext.NavigationService.Journal;
        }
Example #3
0
 public EditUserRoleViewModel(int userRoleId)
 {
     DbConversation.UsingTransaction(() =>
                                     Element = new UserRoleModel(DbConversation.GetById <UserRole>(userRoleId)));
     DisplayName = Strings.EditUserRole_EditUserRole;
 }