package com.example.calendaryapp;

import android.app.Application;

import androidx.annotation.NonNull;
import androidx.lifecycle.AndroidViewModel;
import androidx.lifecycle.LiveData;

import java.util.List;

public class NoteViewModel extends AndroidViewModel {
    private NoteRepository repository;
    private LiveData<List<Note>> allNotes;
    private LiveData<List<Note>> allNotesMar;
    private LiveData<List<Note>> allNotesMie;
    private LiveData<List<Note>> allNotesJue;
    private LiveData<List<Note>> allNotesVie;



    public NoteViewModel(@NonNull Application application) {
        super(application);
        repository = new NoteRepository(application);
        allNotes = repository.getAllNotes();
        allNotesMar = repository.getAllNotesMar();
        allNotesMie = repository.getAllNotesMie();
        allNotesJue = repository.getAllNotesJue();
        allNotesVie = repository.getAllNotesVie();

    }

    public void insert(Note note) {
        repository.insert(note);
    }

    public void update(Note note) {
        repository.update(note);
    }

    public void delete(Note note) {
        repository.delete(note);
    }

    public void deleteAllNotes() {
        repository.deleteAllNotes();
    }

    public LiveData<List<Note>> getAllNotes(int idDay) {
        switch(idDay){
            case 0: return allNotes;
            case 1:return  allNotesMar;
            case 2: return allNotesMie;
            case 3: return allNotesJue;
            case 4: return allNotesVie;
        }
        return allNotes;
    }

}
