Exemplo n.º 1
0
        public void Init()
        {
            // delete 
            Db.UserRoles.DeleteAllOnSubmit(Db.UserRoles); Db.SubmitChanges();
            Db.Users.DeleteAllOnSubmit(Db.Users); Db.SubmitChanges();
            Db.Roles.DeleteAllOnSubmit(Db.Roles); Db.SubmitChanges();

            Division = CreateDivision();
            Role = CreateRole("Role");
            User = CreateUser("User", true);
            UserRole = CreateUserRole(Division, Role, User);

            LoggedUser.SetInstance(User, Division);
        }
Exemplo n.º 2
0
        protected UserRole CreateUserRole(Division division, Role role, User user)
        {
            UserRole userRole = new UserRole();
            userRole.Division = division;
            userRole.Role = role;
            userRole.User = user;

            return userRole;
        }
Exemplo n.º 3
0
 private void TableView_RowCanceled(object sender, RowEventArgs e)
 {
     if (NewItemRow != null && e.RowHandle == GridControl.NewItemRowHandle)
     {
         NewItemRow.User.UserRoles.Remove(NewItemRow);
         NewItemRow = null;
     }
 }
Exemplo n.º 4
0
        protected void AssignUserToDivisions(User user, params Division[] divisions)
        {
            Role role = new Role();
            role.Name = "System administrator";
            
            db.Roles.InsertOnSubmit(role);
            db.SubmitChanges();

            foreach (Division division in divisions)
            {
                UserRole userRole = new UserRole();
                userRole.Division = division;
                userRole.Role = role;
                userRole.User = user;

                db.UserRoles.InsertOnSubmit(userRole);
            }

            db.SubmitChanges();
        }
Exemplo n.º 5
0
        private void TableView_InitNewRow(object sender, InitNewRowEventArgs e)
        {
            NewItemRow = grdRoles.GetRow(e.RowHandle) as UserRole;
            NewItemRow.User = viewModel.SelectedUser;

            e.Handled = true;
        }