Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- controllers/tarefas.go
- ----------------------
- */
- func (c *TarefasController) Insert() {
- var o models.Tarefas
- ret := retorno
- if err := c.ParseForm(&o); err != nil {
- ret["erros"] = 1
- ret["msg"] = "Houve um erro " + err.Error()
- }
- if id, err := models.AddTarefas(&o); err == nil {
- o.Id = int(id)
- aud.Audit (&o, o.TableName(), 0, c.Logged_user_id())
- ret["msg"] = "Registro cadastrado com sucesso"
- } else {
- ret["erros"] = 1
- ret["msg"] = err.Error()
- }
- c.Data["json"] = ret
- c.ServeJson()
- c.Ctx.Redirect(302, "/tarefas")
- }
- /*
- models/tarefa.go
- ----------------------
- */
- func AddTarefas(m *Tarefas) (id int64, err error) {
- o := orm.NewOrm()
- id, err = o.Insert(m)
- return
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement