我想smth。喜歡這個。當用戶鍵入mydomain.com/Message/時,他獲得了所有消息線程,但是當他鍵入mydomain.com/Message/John時,他會在他和約翰之間獲得消息線程。我不知道如何實現鑑於此這裏是控制器:ASP.net MVC一個控制器兩個不同的強類型的VIews
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);
}