Exemplo n.º 1
0
func Delete(c *gin.Context) {
	db := utils.GetDb(c)
	userID := utils.GetUserId(c)
	id := c.Params.ByName("id")
	err, interview := interviewdb.Delete(db, userID, id)
	if err != nil {
		c.Error(err)
		return
	}
	c.JSON(http.StatusOK, interview)
}
Exemplo n.º 2
0
func Delete(c *gin.Context) {
	db := utils.GetDb(c)
	userId := utils.GetUserId(c)
	companyId := c.Params.ByName("id")

	err, company := companydb.Delete(db, userId, companyId)
	if err != nil {
		c.JSON(http.StatusNotFound, companyNotFoundError)
		return
	}

	c.JSON(http.StatusOK, company)
}
Exemplo n.º 3
0
func Delete(c *gin.Context) {
	db := utils.GetDb(c)
	userId := utils.GetUserId(c)
	id := c.Params.ByName("id")
	err, user := vacancydb.DeleteById(db, userId, id)
	if err != nil {
		log.Error(err.Error())
		c.JSON(http.StatusNotFound, notFoundError)
		return
	}

	c.JSON(http.StatusOK, user)
}
Exemplo n.º 4
0
func Delete(c *gin.Context) {
	db := utils.GetDb(c)
	userId := utils.GetUserId(c)
	id := c.Params.ByName("id")
	err, sub := subdb.Delete(db, userId, id)
	if err != nil {
		log.Debug(err)
		c.Error(err)
		return
	}

	interviewdb.GetInterviewC(db).RemoveId(sub.Interview)

	c.JSON(http.StatusOK, sub)
}
Exemplo n.º 5
0
func GetOne(c *gin.Context) {
	db := utils.GetDb(c)
	id := c.Params.ByName("id")
	if id == "me" {
		id = utils.GetUserId(c)
	}

	log.Debug("Userid :%v", id)
	err, user := userdb.GetOneById(db, id)
	if err != nil {
		log.Error(err.Error())
		c.JSON(http.StatusNotFound, userNotFoundError)
		return
	}

	c.JSON(http.StatusOK, user)
}
Exemplo n.º 6
0
func Create(c *gin.Context) {
	err, interview := bindInterview(c)
	if err != nil {
		c.JSON(http.StatusBadRequest, notValidModel(err))
		return
	}

	db := utils.GetDb(c)
	userId := utils.GetUserId(c)
	err = interviewdb.Create(db, userId, interview)
	if err != nil {
		c.Error(err)
		return
	}

	c.JSON(http.StatusCreated, interview)
}
Exemplo n.º 7
0
func Create(c *gin.Context) {
	db := utils.GetDb(c)
	userId := utils.GetUserId(c)

	err, sub := getSub(c)
	if err != nil {
		log.Error("Binding error", err)
		c.Error(err)
		return
	}

	err = subdb.Create(db, userId, sub)
	if err != nil {
		c.Error(err)
		return
	}

	c.JSON(http.StatusCreated, sub)
}
Exemplo n.º 8
0
func Update(c *gin.Context) {
	updateModel := models.InterviewUpdateModel{}
	err := c.BindJSON(&updateModel)
	if err != nil {
		c.JSON(http.StatusBadRequest, notValidModel(err))
		return
	}

	db := utils.GetDb(c)
	id := c.Params.ByName("id")
	userID := utils.GetUserId(c)
	err, updatedInterview := interviewdb.Update(db, userID, id, &updateModel)
	if err != nil {
		c.Error(err)
		return
	}

	c.JSON(http.StatusOK, updatedInterview)
}
Exemplo n.º 9
0
func Update(c *gin.Context) {
	updateModel := models.CompanyUpdateModel{}
	err := c.BindJSON(&updateModel)
	if err != nil {
		c.JSON(http.StatusBadRequest, notValidModel(err))
		return
	}

	db := utils.GetDb(c)
	id := c.Params.ByName("id")
	userID := utils.GetUserId(c)
	err, updatedCompany := companydb.Update(db, userID, id, &updateModel)
	if err != nil {
		c.JSON(http.StatusNotFound, companyNotFoundError)
		return
	}

	c.JSON(http.StatusOK, updatedCompany)
}
Exemplo n.º 10
0
func Create(c *gin.Context) {
	log.Debug("companies.Create")
	err, company := bindCompany(c)
	log.Debug("companies.Create - bindCompany", err, company)
	if err != nil {
		c.JSON(http.StatusBadRequest, notValidModel(err))
		return
	}

	db := utils.GetDb(c)
	userId := utils.GetUserId(c)
	err = companydb.Create(db, userId, company)
	log.Debugf("companies.Create - userId := %v", userId)
	if err != nil {
		c.JSON(http.StatusBadRequest, notValidModel(err))
		return
	}

	c.JSON(http.StatusCreated, company)
}
Exemplo n.º 11
0
func Update(c *gin.Context) {
	id := c.Params.ByName("id")

	updateModel := models.VacancyUpdateModel{}
	err := c.BindJSON(&updateModel)
	if err != nil {
		c.Error(err)
		return
	}

	db := utils.GetDb(c)
	userId := utils.GetUserId(c)
	err, updatedVacancy := vacancydb.Update(db, userId, id, &updateModel)
	if err != nil {
		c.Error(err)
		return
	}

	c.JSON(http.StatusOK, updatedVacancy)
}
Exemplo n.º 12
0
func Create(c *gin.Context) {
	db := utils.GetDb(c)
	userId := utils.GetUserId(c)
	log.Debugf("vacancies.Create, userId:%v", userId)

	err, vacancy := getVacancy(c)
	log.Debug("vacancies.Create - bind Vacancy", err, vacancy)
	if err != nil {
		c.JSON(http.StatusBadRequest, badRequestError)
		return
	}

	err = vacancydb.Create(db, userId, vacancy)
	if err != nil {
		log.Debug("vacancies.Create - err", err)
		c.JSON(http.StatusBadRequest, badRequestError)
		return
	}

	c.JSON(http.StatusCreated, vacancy)
}