Ejemplo n.º 1
0
func (c UserPostController) Remove(id int64) revel.Result {
	revel.TRACE.Printf("GET >> user.post.remove ... (%d)", id)

	c.Begin()
	var obj models.UserPost
	obj.ID = id

	count, err := c.Txn.Delete(&obj)
	if err != nil {
		c.Rollback()
		c.Flash.Error(err.Error())
		return c.Redirect(routes.UserPostController.Index())
	}
	c.Commit()

	if count == 0 {
		c.Flash.Error("user.post (%d) not exist.", id)
	} else {
		c.Flash.Success("user.post (%d) remove succeed.", id)
	}

	return c.Redirect(routes.UserPostController.Index())
}