AddGrade erase any previous grade recorded for the user
continuous-integration/drone/push Build is running
Details
continuous-integration/drone/push Build is running
Details
This commit is contained in:
parent
51a311f0b9
commit
107b17c11f
13
works.go
13
works.go
|
@ -472,6 +472,19 @@ func (u *User) GetMyWorkGrade(w *Work) (g WorkGrade, err error) {
|
|||
}
|
||||
|
||||
func (w *Work) AddGrade(grade WorkGrade) error {
|
||||
u := User{Id: grade.IdUser}
|
||||
|
||||
// Search a previous record
|
||||
g, err := u.GetMyWorkGrade(w)
|
||||
if err != nil && err != sql.ErrNoRows {
|
||||
return err
|
||||
} else if err == nil {
|
||||
_, err = g.Delete()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
return w.AddGrades([]WorkGrade{grade})
|
||||
}
|
||||
|
||||
|
|
Reference in New Issue