/**
   * Returns the player profile page with the submitted info.
   *
   * @return The player profile page, which was just created/edited
   */
  @Security.Authenticated(Secured.class)
  public static Result playerManageSubmit() {
    // adds the new player from the PlayerForm page to the database.
    Form<PlayerFormData> data = Form.form(PlayerFormData.class).bindFromRequest();

    SearchFormData data2 = new SearchFormData();
    Form<SearchFormData> dataForm = Form.form(SearchFormData.class).fill(data2);
    Page<Player> playerPage = Player.find("name asc", 0);
    User user = Secured.getUserInfo(ctx());

    if (data.hasErrors()) {
      Map<String, Boolean> playerSkillMap = PlayerFields.getSkill();
      Map<String, Boolean> playerPosition = PlayerFields.getPosition();
      return badRequest(
          PlayerForm.render(
              "Bad Player Form", data, playerSkillMap, playerPosition, Secured.isLoggedIn(ctx())));
    } else {
      PlayerFormData formData = data.get();
      if (Player.getPlayer(user.getId()) == null) {
        // Player.addPlayer(formData);
      } else {
        Player.updatePlayer(formData, user.getId());
      }

      return ok(
          PlayerList.render(
              playerPage,
              "PlayerList",
              dataForm,
              "none",
              "none",
              Secured.isLoggedIn(ctx()),
              Secured.getUserInfo(ctx())));
    }
  }
 /**
  * Returns the player list page with all players.
  *
  * @return The Player profiles list page.
  */
 @Security.Authenticated(Secured.class)
 public static Result players(String sortOrder, Integer page) {
   SearchFormData data2 = new SearchFormData();
   Form<SearchFormData> dataForm = Form.form(SearchFormData.class).fill(data2);
   Page<Player> playerPage = Player.find(sortOrder, page);
   return ok(
       PlayerList.render(
           playerPage,
           "PlayerList",
           dataForm,
           "none",
           "none",
           Secured.isLoggedIn(ctx()),
           Secured.getUserInfo(ctx())));
 }
  /**
   * Returns the player list page based on name search.
   *
   * @return The Player profiles list page.
   */
  @Security.Authenticated(Secured.class)
  public static Result playerNameSearch() {
    SearchFormData data2 = new SearchFormData();
    Form<SearchFormData> dataForm = Form.form(SearchFormData.class).fill(data2);

    Form<SearchFormData> data = Form.form(SearchFormData.class).bindFromRequest();
    SearchFormData formData = data.get();
    Page<Player> playerPage = Player.find("name", formData.name, "name asc", 1);

    return ok(
        PlayerList.render(
            playerPage,
            "PlayerList",
            dataForm,
            "name",
            formData.name,
            Secured.isLoggedIn(ctx()),
            Secured.getUserInfo(ctx())));
  }