Files
controle-de-estoque-cli/controller/controller.go
T

34 lines
612 B
Go
Raw Normal View History

package controller
import (
"controle-de-estoque/model"
"controle-de-estoque/view"
)
type Controller struct {
inventory *model.Inventory
}
func New(inventory *model.Inventory) *Controller {
return &Controller{inventory: inventory}
}
2026-07-14 22:11:22 -03:00
func (c *Controller) Execute() {
for {
view.ShowMenu()
input, err := view.ReadMenuInput()
2026-07-14 22:11:22 -03:00
if err != nil {
view.ShowError(err)
break
}
switch input {
case "1", "adicionar":
productInput := view.ReadProdutoInput()
p := c.inventory.AdicionarProduto(productInput)
view.ShowMessage("Produto criado com ID %d: %s\n", []any{p.ID, p.Name})
}
}
}