Products

Solutions

Resources

Partners

Community

Blog

About

QA

Ideas Test

New Community Website

Ordinarily, you'd be at the right spot, but we've recently launched a brand new community website... For the community, by the community.

Yay... Take Me to the Community!

Welcome to the DNN Community Forums, your preferred source of online community support for all things related to DNN.
In order to participate you must be a registered DNNizen

HomeHomeDevelopment and...Development and...Building ExtensionsBuilding ExtensionsModulesModulesCreating User Relationship HelpCreating User Relationship Help
Previous
 
Next
New Post
10/3/2012 7:02 AM
 

var aaa = 1  and   int aaa = 1 both map to an Integer = but to be honest using var aaa really makes for lazy code.

But having said that - given i would be questioning the values that are being inserted into the variables not the use of var or int.

in this case you are showing different code passing in different variables to your test functions - in this case the Value of hfFriendId is the one I would be suspect of.

But again seriously - STOP using vars - it makes for code that you will never understand in the future.  Yes vars do have a place when using linq and other complex constructs - but for day to day coding they really should be avoided - if you are using an int define it as an int.

Westa

 
New Post
10/3/2012 12:22 PM
 

I have since changed to use a int instead of var. The content of the in is

int friendId = Convert.toInt32(hfFriendId.Value);

hfFriendId is defined from a hidden field in a list view

HiddenField hfFriendId = item.FindControl("hfFriendId") as HiddenField

Now, Just for sanity sake I tried 

int otherId = 100;
UserInfo TargetUser = UserController.GetUserById(base.PortalId, otherId);

and this also gives a null TargetUser. 


 
New Post
10/3/2012 6:59 PM
 
Which come down to the same questions - i would be looking at the validity of the values you are using.

Look at base.PortalId for starters - traditionally we get PortalId from portalsettings.current.PortalId - i would check that there is an actual value in base.PortalId.

Westa
 
New Post
10/3/2012 8:46 PM
 

thanks for the ongoing help

I can see during debug portal id is returning the proper portal id and the second int is returning a value but at the end TargetUser is not populated.

I have tried multiple combinations including 
UserController.GetUserById(21, FriendId) fails
UserController.GetUserById(PortalSettings.PortalId, FriendId); fails

UserInfo InitiatingUser = UserController.GetUserById(21, 97); works
UserInfo InitiatingUser = UserController.GetUserById(base.PortalId, 97); works
UserController.GetUserById(PortalSettings.PortalId, UserInfo.UserID); works

I have seen so many examples of an int being passed successfully in the memberdirectory module and others.. I don't get why it does work in my case.


 
New Post
10/3/2012 10:10 PM
 

At this point its down to user error.

Show us the entire block of user code that is causing you issues.  You keep showing us small lines of code without context.

Try doing something like this

Int32 thisPortal = PortalSettings.PortalId;
Int32 thisFriendId = 97;

Debug at this point -

UserInfo InitiatingUser = UserController.GetUserById(thisPortal , thisFriendId);

Int32 testUserId = InitiatingUser.UserId;

Debug again at this point

There is no reason whatever why this would not work - what im willing to bet is that you still have a var mapping issue or a typo burried somewhere.  There are litterally millions of websites and modules in use all over the internet that work with this exact same code.

Westa



 
Previous
 
Next
HomeHomeDevelopment and...Development and...Building ExtensionsBuilding ExtensionsModulesModulesCreating User Relationship HelpCreating User Relationship Help


These Forums are dedicated to discussion of DNN Platform and Evoq Solutions.

For the benefit of the community and to protect the integrity of the ecosystem, please observe the following posting guidelines:

  1. No Advertising. This includes promotion of commercial and non-commercial products or services which are not directly related to DNN.
  2. No vendor trolling / poaching. If someone posts about a vendor issue, allow the vendor or other customers to respond. Any post that looks like trolling / poaching will be removed.
  3. Discussion or promotion of DNN Platform product releases under a different brand name are strictly prohibited.
  4. No Flaming or Trolling.
  5. No Profanity, Racism, or Prejudice.
  6. Site Moderators have the final word on approving / removing a thread or post or comment.
  7. English language posting only, please.
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out