private void ContactItemEventHandler(object sender, EventArgs e) { ContactItemSelectedArgs item = e as ContactItemSelectedArgs; ConversationWithOther conver = new ConversationWithOther(); conver.Name = "Noname conversation"; conver.UserIds = new long[] { item.userId }; using (HttpClient client = new HttpClient()) { client.BaseAddress = new Uri(Ultils.getUrl()); client.DefaultRequestHeaders.Accept.Clear(); client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", AppInstance.getInstance().GetUser().Token); HttpResponseMessage response = client.PostAsJsonAsync("/api/Conversations/WithMembers", conver).Result; if (response.StatusCode == System.Net.HttpStatusCode.Conflict || response.StatusCode == System.Net.HttpStatusCode.OK)//trùng hoặc vừa tạo mới { Conversation conversation = response.Content.ReadAsAsync <Conversation>().Result; RightPanel.Children.Clear(); ChattingPanel chattingPanel = new ChattingPanel(conversation.Id); RightPanel.Children.Add(chattingPanel); } else { } } }
private void HistoryItemEventHandler(object sender, EventArgs e) { HistoryItemSelectedArgs itemindex = e as HistoryItemSelectedArgs; long pkseq = itemindex.pk_seq; RightPanel.Children.Clear(); ChattingPanel chattingPanel = new ChattingPanel(pkseq); RightPanel.Children.Add(chattingPanel); //chattingPanel.LoadMessageAsync().Wait(); ; }