예제 #1
0
파일: program.go 프로젝트: naikparag/lego
func (this *CCProgramHandler) DeleteProgram(c *gin.Context) {
	fmt.Println("Deleting  Programs - ")
	session := util.GetDBSession()
	dbObj := session.DB(util.DB_Name).C(util.DB_Program)

	filter := util.ExtractProgramFilter(c)
	err := dbObj.Remove(filter)
	if err != nil {
		fmt.Println("Unable to remove data - ", err.Error())
	}
}
예제 #2
0
파일: program.go 프로젝트: naikparag/lego
func (this *CCProgramHandler) FetchAllPrograms(c *gin.Context) models.Program_List {
	fmt.Println("Fetching all events - ")
	filter := util.ExtractProgramFilter(c)
	var err error

	results := []models.CCProgram{}
	if filter != nil {
		fmt.Println("Reached - ")
		err = dbObj.Find(filter).All(&results)
	} else {
		fmt.Println("Reached to All- ")
		err = dbObj.Find(nil).All(&results)
	}

	if err != nil {
		fmt.Println("Unable to fetch data - ", err.Error())
	}
	programs := models.Program_List{Programs: results}
	return programs

}