vikunja-api/models/teams_update.go

26 lines
402 B
Go
Raw Normal View History

2018-07-14 18:29:24 +02:00
package models
// Update is the handler to create a team
func (t *Team) Update() (err error) {
2018-07-14 18:29:24 +02:00
// Check if we have a name
if t.Name == "" {
return ErrTeamNameCannotBeEmpty{}
}
// Check if the team exists
_, err = GetTeamByID(t.ID)
2018-07-14 18:29:24 +02:00
if err != nil {
return
}
_, err = x.ID(t.ID).Update(t)
2018-07-14 18:29:24 +02:00
if err != nil {
return
}
// Get the newly updated team
*t, err = GetTeamByID(t.ID)
2018-07-14 18:29:24 +02:00
return
}