1
0

Implemented team update method

This commit is contained in:
konrad
2018-07-14 18:29:24 +02:00
committed by kolaente
parent bcbd415529
commit 4cf0cd233c
9 changed files with 96 additions and 10 deletions

25
models/teams_update.go Normal file
View File

@ -0,0 +1,25 @@
package models
// Update is the handler to create a team
func (t *Team) Update(id int64) (err error) {
// Check if we have a name
if t.Name == "" {
return ErrTeamNameCannotBeEmpty{}
}
// Check if the team exists
_, err = GetTeamByID(id)
if err != nil {
return
}
_, err = x.ID(id).Update(t)
if err != nil {
return
}
// Get the newly updated team
*t, err = GetTeamByID(id)
return
}