public User GetUserForUsername(string _Username)
        {
            var data = UserProcessor.SelectUserForUsername(_Username);

            data = UserProcessor.SelectUserWithRoles(data.UserId);

            var user = new User
            {
                UserId       = data.UserId,
                Username     = data.Username,
                FirstName    = data.FirstName,
                LastName     = data.LastName,
                EmailAddress = data.Email,
                PhoneNumber  = data.PhoneNo,
                Password     = data.Password,
            };

            foreach (var userRoleData in data.UserRoles)
            {
                var userRole = new UserRole( );
                userRole.RoleId = userRoleData.RoleId;
                userRole.UserId = userRoleData.UserId;
                userRole.User   = user;

                var roleData = RoleProcessor.SelectRoleWithPermissions(userRoleData.RoleId);
                var role     = new Role( );
                role.RoleId = roleData.RoleId;
                role.Name   = roleData.Name;
                foreach (var rolePermissionData in roleData.RolePermissions)
                {
                    var rolePermission = new RolePermission( );
                    rolePermission.RoleId       = rolePermissionData.RoleId;
                    rolePermission.PermissionId = rolePermissionData.RoleId;
                    rolePermission.Role         = role;

                    var permissionData = PermissionProcessor.SelectPermission(rolePermissionData.PermissionId);
                    var permission     = new Permission(permissionData);

                    rolePermission.Permission = permission;

                    role.RolePermissions.Add(rolePermission);
                }
                userRole.Role = role;
                user.UserRoles.Add(userRole);
            }

            return(user);
        }
        public List <RolePermission> getRolePermissionByRoleId(int roleId)
        {
            var roleData = RoleProcessor.SelectRoleWithPermissions(roleId);
            var role     = new Role( );

            role.RoleId = roleData.RoleId;
            role.Name   = roleData.Name;
            foreach (var rolePermissionData in roleData.RolePermissions)
            {
                var rolePermission = new RolePermission( );
                rolePermission.RoleId       = rolePermissionData.RoleId;
                rolePermission.PermissionId = rolePermissionData.RoleId;
                rolePermission.Role         = role;

                var permissionData = PermissionProcessor.SelectPermission(rolePermissionData.PermissionId);
                var permission     = new Permission( );
                permission.PermissionId   = permissionData.PermissionId;
                permission.PermissionName = permissionData.PermissionName;
                rolePermission.Permission = permission;

                role.RolePermissions.Add(rolePermission);
            }
            return(role.RolePermissions.ToList( ));
        }