/// <summary> /// Adds the given season to the team with the matching team ID. /// </summary> /// <param name="teamID">The ID of the team of interest.</param> /// <param name="season">The season to be added to the team of interest.</param> /// <returns>A message detailing the result of the addition.</returns> public ActionResult AJAX_AddSeason(long teamID, short season) { string result = "Request is not authenticated."; if (Request.IsAuthenticated) { 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())) { result = "Error adding season " + season + " to " + team.name + "."; if (dba.AddSeason(teamID, season)) { result = "Season " + season + " added to " + team.name + "."; } } else { result = "You must be a coach of the team to add a season."; LogEntry entry = new LogEntry(LogType.INVALID_REQUEST, LogFunction.ADD_SEASON, LogAction.NA); entry.User = user; entry.Message = "Attempt to add a season to "+team.name + " (" + team.ID + ")."; dba.LogMessage(entry); } } return Json( new { message = result }, JsonRequestBehavior.AllowGet ); }