MCPcopy Create free account
hub / github.com/Cawlumm/lyftr / UpdateProgram

Method UpdateProgram

backend/controllers/programs.go:70–99  ·  view source on GitHub ↗
(c *gin.Context)

Source from the content-addressed store, hash-verified

68 return
69 }
70 utils.OK(c, p)
71}
72
73func (h *Handler) CreateProgram(c *gin.Context) {
74 uid := middleware.UserID(c)
75 var req models.CreateProgramRequest
76 if err := c.ShouldBindJSON(&req); err != nil {
77 utils.BadRequest(c, utils.BindMessage(err))
78 return
79 }
80 if err := validate.Struct(req); err != nil {
81 utils.ValidationError(c, err)
82 return
83 }
84 p, err := h.s.Program.Create(uid, req)
85 if utils.IsForeignKeyViolation(err) {
86 utils.BadRequest(c, "One or more of those exercises no longer exist.")
87 return
88 }
89 if utils.DBError(c, err) {
90 return
91 }
92 utils.Created(c, p)
93}
94
95func (h *Handler) UpdateProgram(c *gin.Context) {
96 uid := middleware.UserID(c)
97 pid, err := strconv.ParseInt(c.Param("id"), 10, 64)
98 if err != nil {
99 utils.BadRequest(c, "That program id isn't valid.")
100 return
101 }
102 var req models.CreateProgramRequest

Callers 1

Calls 1

UpdateMethod · 0.45

Tested by 1