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) }
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) }
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) }
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) }
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) }
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) }
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) }
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) }
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) }
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) }
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) }
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) }