private void AddRequestToContacts(UserInfoContainer container) { int contactListBottom = GetContactsListLength(); int requestId = 0; // Get the ID of the request itself foreach (RequestInformation request in this.requests) { if (request.Requester.Id == container.UserId) { requestId = request.Id; break; } } RepositionRemainingRequests(container); container.Location = new Point(0, contactListBottom); contactListBottom += container.Height; container.Parent = this.pnlContactsContainer; this.pnlContactsContainer.Controls.Add(container); this.listContactContainer.Add(container); int offset = GetContactsListLength(); this.pnlAvailableRequests.Location = new Point(this.pnlAvailableRequests.Location.X, offset); // Send query to the API so that we actually add the user to the database WebConnector.AddContact(this.accountInfo.Id, container.UserId); // Remove the request WebConnector.DeleteRequest(requestId); // Tell server to propagate the request to the accepted client if he's currently available string jsonClientInfo = JsonConvert.SerializeObject(this.accountInfo); // Send as message socketHelper.SendMessage(container.Username, jsonClientInfo, this.accountInfo.Username, @"/accept"); }