//Note : Grabs Note by the ID func (nc *NotesController) Note(c *gin.Context) { resp := response.New(c) defer resp.Render() noteID, err := strconv.Atoi(c.Param("noteId")) if err != nil { resp.AddErrorDetail(400, err) return } note, err := services.Note(noteID) if err != nil { resp.AddErrorDetail(500, err) return } resp.SetResponse(200, note) return }
//DeleteNote : Deletes a note from the database func (nc *NotesController) DeleteNote(c *gin.Context) { resp := response.New(c) defer resp.Render() noteID, err := strconv.Atoi(c.Param("noteId")) if err != nil { resp.AddErrorDetail(400, err) resp.StatusCode = 400 return } err = services.DeleteNote(noteID) if err != nil { resp.AddErrorDetail(400, err) resp.StatusCode = 400 return } resp.SetResponse(200, gin.H{"message": "Successfully Deleted Note"}) return }