package com.ttstd.dialer.db.contact;

import android.app.Application;

import androidx.lifecycle.AndroidViewModel;

import java.util.List;

public class ContactViewModel extends AndroidViewModel {
    private ContactRepository mRepository;

    public ContactViewModel(Application application) {
        super(application);
        mRepository = new ContactRepository(application);
    }

    public List<ContactInfo> getAllContacts() {
        return mRepository.getAllContacts();
    }

    public ContactInfo getContactById(int id) {
        return mRepository.getContactById(id);
    }

    public List<ContactInfo> searchContacts(String query) {
        return mRepository.searchContacts(query);
    }

    public void insert(ContactInfo contactInfo) {
        mRepository.insert(contactInfo);
    }

    public void update(ContactInfo contactInfo) {
        mRepository.update(contactInfo);
    }

    public void delete(ContactInfo contactInfo) {
        mRepository.delete(contactInfo);
    }

    public void deleteById(int id) {
        mRepository.deleteById(id);
    }

    public void deleteAll() {
        mRepository.deleteAll();
    }
}
