/// <summary> /// Returns an HTML table of the invites that the authenticated user has initiated /// and are still open. /// </summary> /// <returns></returns> public ActionResult AJAX_GetOpenInviteTable() { string result = "<p>Could not authenticate the request.</p>\n"; if (Request.IsAuthenticated) { DBAccessor dba = new DBAccessor(); Person user = dba.GetPersonInformation(User.Identity.Name); if (user.permissions.coachEnabled) { result = ""; // Call the database to get pending requests List<Invitation> invitations = dba.GetMyOpenInvites(User.Identity.Name); // Form an HTML table with the retrieved information if (invitations.Any()) { result += "<table>\n"; result += "<tr><th>Invited</th><th>To Join</th><th>Sent On</th><th>Remove</th></tr>\n"; foreach (Invitation invitation in invitations) { result += "<tr><td>" + invitation.invitee + "</td><td>" + invitation.team.name + "</td><td>" + invitation.timestamp.ToString("m") + "</td>"; result += "<td><div onClick='action_removeinvite(" + invitation.ID + ")' class='request-action-text clickable-text'>Remove</div></td></tr>"; } result += "</table>\n"; } else { result += "<p>You have no open invites at this time.</p>\n"; } } else { result = ""; } } return Json( new { message = result }, JsonRequestBehavior.AllowGet ); }