/// <summary> /// Returns a list of the pending invites associated with the authenticated user. /// </summary> /// <returns></returns> public ActionResult AJAX_GetInviteTable() { string result = "<p>Could not authenticate the request.</p>\n"; if (Request.IsAuthenticated) { DBAccessor dba = new DBAccessor(); Person person = dba.GetPersonInformation(User.Identity.Name); result = ""; // Call the database to get pending requests List<Invitation> invitations = dba.GetInvites(User.Identity.Name); // Form an HTML table with the retrieved information if (invitations.Any()) { result += "<table>\n"; result += "<tr><th>Invitation From</th><th>Invitation to Join</th><th>Action</th></tr>\n"; foreach (Invitation invitation in invitations) { string playerName = invitation.invitor.firstName + " " + invitation.invitor.lastName; result += "<tr><td>" + playerName + "</td><td>" + invitation.team.name + "</td>"; result += "<td><img src='./../Content/images/accept.png' height='20' width='20' class='request-action-image' alt='accept' onClick='action_acceptinvite(" + invitation.ID + ")' />"; result += "<img src='./../Content/images/decline.png' height='20' width='20' class='request-action-image' margin-right='5px' alt='decline' onClick='action_declineinvite(" + invitation.ID + ")' />"; result += "<div onClick='action_detailsinvite(" + invitation.ID + ")' class='request-action-text clickable-text'>Details</div></td></tr>"; } result += "</table>\n"; } else { result += "<p>There are no pending invites at this time.</p>\n"; } } return Json( new { message = result }, JsonRequestBehavior.AllowGet ); }