/// <summary> /// Removes a team from the database with the matching teamID. /// </summary> /// <param name="teamID">The ID of the team to remove from the database.</param> /// <returns>A message telling if the removal was successful.</returns> public ActionResult AJAX_RemoveTeam(long teamID) { string result = "Request not authenticated."; if (Request.IsAuthenticated) { // Get the team that is to be removed to validate the authenticated user can remove it DBAccessor dba = new DBAccessor(); Team team = dba.GetTeamDetails(teamID); Person user = new Person(); user.email = User.Identity.Name; if (team.coaches.Contains(user, new PersonComparer())) { if (dba.RemoveTeam(teamID)) { result = "Team removed successfully."; } else { result = "Error removing the team from the database."; } } else { result = "Invalid attempt to remove team."; LogEntry entry = new LogEntry(LogType.INVALID_REQUEST, LogFunction.REMOVE_TEAM, LogAction.NA); entry.User = user; entry.Message = "Attempt to remove the team " + team.name + "(ID: " + team.ID + ")."; dba.LogMessage(entry); } } // Return the success message of the addition return Json( new { message = result }, JsonRequestBehavior.AllowGet ); }