Skip to content

Commit

Permalink
rewriting how redshirting call works
Browse files Browse the repository at this point in the history
  • Loading branch information
CalebRose committed Apr 27, 2024
1 parent 3236655 commit 6f3f85f
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 9 deletions.
11 changes: 3 additions & 8 deletions controller/PlayerController.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"encoding/json"
"fmt"
"net/http"
"strconv"

"github.com/CalebRose/SimFBA/managers"
"github.com/CalebRose/SimFBA/structs"
Expand Down Expand Up @@ -92,14 +91,10 @@ func UpdateCollegePlayer(w http.ResponseWriter, r *http.Request) {
// ToggleRedshirtStatusForPlayer
func ToggleRedshirtStatusForPlayer(w http.ResponseWriter, r *http.Request) {
// Update DTO for College Player
var redshirtDTO structs.RedshirtDTO
err := json.NewDecoder(r.Body).Decode(&redshirtDTO)
if err != nil {
http.Error(w, err.Error(), http.StatusBadRequest)
return
}
vars := mux.Vars(r)
PlayerID := vars["PlayerID"]

managers.SetRedshirtStatusForPlayer(strconv.Itoa(redshirtDTO.PlayerID))
managers.SetRedshirtStatusForPlayer(PlayerID)

fmt.Println(w, "College Player successfully redshirted.")
}
Expand Down
2 changes: 1 addition & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ func handleRequests() {
myRouter.HandleFunc("/collegeplayers/team/{teamID}/", controller.AllCollegePlayersByTeamID).Methods("GET")
myRouter.HandleFunc("/collegeplayers/team/nors/{teamID}/", controller.AllCollegePlayersByTeamIDWithoutRedshirts).Methods("GET")
myRouter.HandleFunc("/collegeplayers/team/export/{teamID}/", controller.ExportRosterToCSV).Methods("GET")
myRouter.HandleFunc("/collegeplayers/assign/redshirt/", controller.ToggleRedshirtStatusForPlayer).Methods("POST")
myRouter.HandleFunc("/collegeplayers/assign/redshirt/{PlayerID}", controller.ToggleRedshirtStatusForPlayer).Methods("GET")
myRouter.HandleFunc("/nflplayers/team/{teamID}/", controller.AllNFLPlayersByTeamIDForDC).Methods("GET")
myRouter.HandleFunc("/nflplayers/freeagency/available/{teamID}", controller.FreeAgencyAvailablePlayers).Methods("GET")
myRouter.HandleFunc("/nflplayers/team/export/{teamID}/", controller.ExportNFLRosterToCSV).Methods("GET")
Expand Down

0 comments on commit 6f3f85f

Please sign in to comment.