feat: adicionando o cadastro de produto
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
package controller
|
||||
|
||||
import (
|
||||
"bufio"
|
||||
"controle-de-estoque/model"
|
||||
"controle-de-estoque/view"
|
||||
)
|
||||
@@ -14,8 +13,21 @@ func New(inventory *model.Inventory) *Controller {
|
||||
return &Controller{inventory: inventory}
|
||||
}
|
||||
|
||||
func (c *Controller) CapturarComando(scanner *bufio.Scanner) {
|
||||
view.ExibirMenu()
|
||||
func (c *Controller) Execute() {
|
||||
for {
|
||||
view.ShowMenu()
|
||||
input, err := view.ReadMenuInput()
|
||||
|
||||
// scanner.Scan()
|
||||
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})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user