public ActionResult Index() { if (Globals.isLoggedIn() == false) { return(RedirectToAction("Index", "Authentication")); } ServiceBusConnection connection = ConnectionManager.getConnectionObject(Globals.getUser()); if (connection == null) { return(RedirectToAction("Index", "Authentication")); } GetChatContacts getContactsCommand = new GetChatContacts { usersname = Globals.getUser(), contactNames = null }; GetChatContactsRequest contactsRequest = new GetChatContactsRequest(getContactsCommand); GetChatContactsResponse contactsResponse = connection.getAllChatContacts(contactsRequest); ChatHistory firstDisplayedChatHistory = null; if (contactsResponse.responseData.contactNames.Count != 0) { GetChatHistory getHistoryCommand = new GetChatHistory() { history = new ChatHistory { user1 = Globals.getUser(), user2 = contactsResponse.responseData.contactNames[0] } }; GetChatHistoryRequest historyRequest = new GetChatHistoryRequest(getHistoryCommand); firstDisplayedChatHistory = connection.getChatHistory(historyRequest).responseData.history; } else { firstDisplayedChatHistory = new ChatHistory(); } ViewBag.ChatInstances = contactsResponse.responseData.contactNames; ViewBag.DisplayedChatHistory = firstDisplayedChatHistory; return(View()); }