package org.cmh.backend.UserManagement.service;

import org.cmh.backend.UserManagement.model.Tenant;
import org.cmh.backend.UserManagement.repository.TenantManagementRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;

@Service
public class TenantManagementService {

    @Autowired
    private TenantManagementRepository tenantManagementRepository;

    public Tenant registerTenant(Tenant tenant) {
        return tenantManagementRepository.save(tenant);
    }

    public List<Tenant> findAll(){
        return tenantManagementRepository.findAll();
    }

    public Tenant update(Tenant tenant){return tenantManagementRepository.save(tenant);}

    public Tenant delete(String name){return tenantManagementRepository.deleteByName(name);}

    public void delete(Long id){tenantManagementRepository.deleteById(id);}
}
