func (c UserAccountController) CreatePost(obj models.UserAccount) revel.Result { revel.TRACE.Printf("POST >> user.account.create create ... (%v)", obj) obj.Validate(c.Validation) if c.Validation.HasErrors() { c.Validation.Keep() c.FlashParams() return c.Redirect(UserAccountController.Create) } c.Begin() if err := c.Txn.Insert(&obj); err != nil { c.Rollback() c.Flash.Error(err.Error()) return c.Redirect(routes.UserAccountController.Index()) } c.Commit() c.Flash.Success("user.account (%d) create succeed.", obj.ID) return c.Redirect(routes.UserAccountController.Index()) }
func (c UserAccountController) Remove(id int64) revel.Result { revel.TRACE.Printf("GET >> user.account.remove ... (%d)", id) c.Begin() var obj models.UserAccount obj.ID = id count, err := c.Txn.Delete(&obj) if err != nil { c.Rollback() c.Flash.Error(err.Error()) return c.Redirect(routes.UserAccountController.Index()) } c.Commit() if count == 0 { c.Flash.Error("user.account (%d) not exist.", id) } else { c.Flash.Success("user.account (%d) remove succeed.", id) } return c.Redirect(routes.UserAccountController.Index()) }