Esempio n. 1
0
// Delete translation from top competition
func (controller *TopCompetitionController) RemoveCompetition(dbMap *gorp.DbMap, r *http.Request) *ControllerResponse {
	var err error
	vars := mux.Vars(r)
	if err = model.GetTopCompetitionManager(dbMap).RemoveCompetition(vars["entity_id"], vars["child_id"]); err != nil {
		new(syslog.Writer).Err(fmt.Sprintf("%s %s Details: %s\n", controller.getLogPrefix(), controller.GetResponseMessage("RemoveCompetitionError"), err))
		return controller.GetErrorControllerResponse(http.StatusInternalServerError, GeneralServerErrorCode, "DB: "+err.Error())
	}

	return controller.GetSuccessControllerResponse(http.StatusOK, controller.GetResponseMessage("RemoveCompetitionSuccess"), Empty{})
}
Esempio n. 2
0
// Read top list
func (controller *TopCompetitionController) Read(dbMap *gorp.DbMap, r *http.Request) *ControllerResponse {
	var (
		competitionList *[]model.TopCompetitionCompetition
		err             error
	)
	vars := mux.Vars(r)
	if competitionList, err = model.GetTopCompetitionManager(dbMap).ListCompetitions(vars["id"]); err != nil {
		new(syslog.Writer).Err(fmt.Sprintf("%s %s Details: %s\n", controller.getLogPrefix(), controller.GetResponseMessage("ReadError"), err))
		return controller.GetErrorControllerResponse(http.StatusInternalServerError, GeneralServerErrorCode, "DB: "+err.Error())
	}

	if competitionList == nil {
		return controller.GetErrorControllerResponse(http.StatusNotFound, GeneralServerErrorCode, controller.GetResponseMessage("NotFound"))
	}

	return controller.GetSuccessControllerResponse(http.StatusOK, controller.GetResponseMessage("ReadSuccess"), controller.GetResponseData(competitionList))
}