package com.service.impl;

import com.entity.Project;
import com.repository.MemberProjectRepository;
import com.repository.ProjectRepository;
import com.service.ProjectService;
import org.springframework.beans.factory.annotation.Autowired;
import java.sql.SQLException;
import java.util.List;

/**
 *
 * Implementation of the project service.
 *
 * @author Laurentiu Marcut
 */
public class ProjectServiceImpl implements ProjectService {

    @Autowired
    private ProjectRepository projectRepository;

    @Autowired
    private MemberProjectRepository memberProjectRepository;

    @Override
    public List<Project> selectAll(String member) throws SQLException {
        return projectRepository.selectAll(member);
    }

    @Override
    public void insert(String project, String createdBy, String role) throws SQLException {
        this.projectRepository.insert(project, createdBy);
        this.memberProjectRepository.insert(project, createdBy, role);
    }

    @Override
    public void delete(String project) throws SQLException {
        this.projectRepository.delete(project);
    }

}
