Started agent view

This commit is contained in:
Simon Martens
2024-12-08 21:47:05 +01:00
parent 425e4bb53d
commit 79712349a0
5 changed files with 56 additions and 24 deletions

25
viewmodels/agentsvm.go Normal file
View File

@@ -0,0 +1,25 @@
package viewmodels
import (
"strings"
"github.com/Theodor-Springmann-Stiftung/kgpz_web/providers/xmlprovider"
)
type AgentView struct {
Agents []xmlprovider.Agent
}
func AgentsView(letterorid string, lib *xmlprovider.Library) *AgentView {
res := AgentView{}
lib.Agents.Items.Range(func(key, value interface{}) bool {
k := key.(string)
if strings.HasPrefix(k, letterorid) {
agent := value.(xmlprovider.Agent)
res.Agents = append(res.Agents, agent)
}
return true
})
return &res
}