我想要…… 像这样。当用户键入 mydomain.com/Message/ 时,他得到了他所有的消息线程,但是当他键入 mydomain.com/Message/John 时,他得到了他和 john 之间的消息线程。我不知道如何为此实现视图是控制器:
public ActionResult Index(String userName)
{
var user = UserRepository.GetUserByDisplayName(userName);
if (user == null || user.UserId.Equals(WebSecurity.CurrentUserId))
{
IQueryable<MessageThread> messageThreads =
MessageThreadRepository.GetMessageThreadsForUser(WebSecurity.CurrentUserId);
return View(messageThreads);
}
MessageThread thread = MessageThreadRepository.GetThreadBetweenUsers(WebSecurity.CurrentUserId, userName);
return View(thread);
}