package com.uca.core;

import com.uca.core.*;
import com.uca.dao.*;
import com.uca.entity.*;
import java.util.*;


public class ProfCore extends _DefaultCore<ProfEntity> {

    public static final ProfCore Instance = new ProfCore();

    private ProfCore()
    {
        super(new ProfDAO());
    }

    public ProfEntity create(String firstName, String lastName, String userName, String password) {
        ProfEntity entity = new ProfEntity();
        entity.setFirstName(firstName);
        entity.setLastName (lastName);
        entity.setUserName (userName);
        entity.setPassword(password);
        return dao.create(entity);
    }

    public ProfEntity getByLoginPair(String username, String password)
    {
        for(ProfEntity p : dao.getAll())
        {
            if(p.getUserName().compareTo(username) == 0 && p.getPassword().compareTo(password) == 0)
            {
                return p;
            }
        }
        return null;
    }
}