fix find existing if more than one record
This commit is contained in:
@@ -54,9 +54,15 @@ func (dh *DatabaseHandler) responsibleExists(CheckResponsible models.Person) (bo
|
||||
return false, errors.New("database not opened")
|
||||
}
|
||||
|
||||
var person models.Person
|
||||
if !dh.database.Exists(&person, "lastName", CheckResponsible.LastName, false) {
|
||||
var persons []models.Person
|
||||
if !dh.database.Exists(&persons, "lastName", CheckResponsible.LastName, false) {
|
||||
return false, nil
|
||||
}
|
||||
return person.FirstName == CheckResponsible.FirstName && person.LastName == CheckResponsible.LastName, nil
|
||||
|
||||
for _, person := range persons {
|
||||
if person.FirstName == CheckResponsible.FirstName && person.LastName == CheckResponsible.LastName {
|
||||
return true, nil
|
||||
}
|
||||
}
|
||||
return false, nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user