Example #1
0
//DeleteNote : Deletes note
func DeleteNote(id int) error {
	var note models.Note
	err := note.FetchNoteByID(id)

	if err != nil { //err? return
		return err
	}
	log.Println(note)
	if note.NoteID != 0 {
		note.Delete()
	} else {
		msg := fmt.Sprintf("Note ID %d is not in the database", id)
		err = errors.New(msg)
	}

	return nil
}
Example #2
0
//CreateNewNote : Creates new note using the note model
func CreateNewNote(name, body string, userID int) error {

	n := models.Note{
		NoteName: name,
		NoteBody: body,
		UserID:   userID,
	}

	log.Println(n)

	err := n.NewNote()

	if err != nil {
		return err
	}

	log.Println(n)
	return nil

}