func CreateNote(w http.ResponseWriter, r *http.Request) {
	fmt.Println("------------------ CreateNote ------------------")

	note := model.Note{}

	fmt.Println(r)

	decoder := json.NewDecoder(r.Body)

	err := decoder.Decode(&note)

	if err != nil {
		log.Fatal(err)
		w.WriteHeader(http.StatusInternalServerError)
		return
	}

	note.Id = bson.NewObjectId()

	err = data.InsertNote(note)

	if err != nil {
		w.WriteHeader(http.StatusInternalServerError)
		fmt.Fprintf(w, err.Error())
		return
	}

	j, err := json.Marshal(note)

	if err != nil {
		log.Fatal(err)
		w.WriteHeader(http.StatusInternalServerError)
		return
	}
	w.WriteHeader(http.StatusCreated)
	fmt.Fprintf(w, string(j))
}
func UpdateNote(w http.ResponseWriter, r *http.Request) {
	fmt.Println("------------------ UpdateNote ------------------")

	vars := mux.Vars(r)
	if bson.IsObjectIdHex(vars["id"]) {

		id := bson.ObjectIdHex(vars["id"])
		note := model.Note{}

		decoder := json.NewDecoder(r.Body)

		err := decoder.Decode(&note)
		if err != nil {
			log.Fatal(err)
			w.WriteHeader(http.StatusInternalServerError)
			return
		}
		note.Id = id

		data.UpdateNote(note)

		j, err := json.Marshal(note)

		if err != nil {
			log.Fatal(err)
			w.WriteHeader(http.StatusInternalServerError)
			return
		}

		fmt.Fprintf(w, string(j))

	} else {
		w.WriteHeader(http.StatusBadRequest)
		return
	}
}