November Happy Hour will be moved to Thursday December 5th.

Adding new rooms/topics and immediately getting ID back

Vote:
 

See code below:

Topic relateTopic = new Topic(currentPage.GetForumRoom(), topic.Title, topic.Body, new UserAuthor(CurrentCommunityUser));
ForumHandler.Instance.AddTopic(relateTopic);

return RedirectToAction("ViewTopic", new { id = relateTopic.ID });

------------------

In the above, the relateTopic.ID is always -1.  How do I immediately get the newly created topic ID back so I can take some further action with it? 

#89225
Aug 11, 2014 20:11
Vote:
 

Hi Shawn,

According to the SDK this is how it is suppose to be done, the AddTopic method takes a topic and persists it in the database. However I see that you do not use the return value from AddTopic and assign it to your created topic:

relateTopic = ForumHandler.Instance.AddTopic(relateTopic);

/T

#89235
Aug 12, 2014 1:20
This thread is locked and should be used for reference only. Please use the Legacy add-ons forum to open new discussions.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.