package br.com.efraimgentil.speakwithme.persistence;

import javax.enterprise.inject.Alternative;

import br.com.efraimgentil.speakwithme.model.User;
import br.com.efraimgentil.speakwithme.model.constants.UserType;

@Alternative
public class UserDAOMemory implements UserDAO {

  @Override
  public User persist(User user) {
    return user;
  }
  
  @Override
  public User userByEmailAndPassword(String email, String password) {
    if("efraim.gentil@gmail.com".equals( email ) && "secretlol".equals(password) ){
      return owner();
    }else if("123654".equals(password)){
      return guest(email);
    }
    return null;
  }
  
  private User owner(){
    User u = new User();
    u.setEmail("efraim.gentil@gmail.com");
    u.setUsername("efraimgentil");
    u.setUserType( UserType.OWNER );
    return u;
  }
  
  private User guest(String email){
    User u = new User();
    u.setEmail(email);
    u.setUsername(email);
    u.setUserType( UserType.GUEST );
    return u;
  }


}
