package com.application.tak.takapplication.data_model;

import android.widget.Toast;

import java.util.regex.Pattern;

/**
 * Created by azielinska on 11/05/2017.
 */
public class User
{
    private Integer _Id;
    private String _LName = "";
    private String _FName = "";
    private String _Username = "";
    private String _PhoneNo = "";
    private Integer _RoleId;
    private Integer _IsActive;
    private Integer _AdressId;
    private Integer _ClassId;
    private String _Password = "";
    private String _ExternAppId;

    //for local db purposes
    private Integer _IsLoggedIn;

    public Integer get_Id() {
        return _Id;
    }

    public void set_Id(int _Id) {
        this._Id = _Id;
    }

    public String get_LName() {
        return _LName;
    }

    public void set_LName(String _LName, int length)
    {
        if(CheckIsDataCorrect(_LName,length))
            this._LName = _LName;
        else this._LName = "";
    }

    public void set_LName(String _LName)
    {
        if(CheckIsDataCorrect(_LName,1))
            this._LName = _LName;
        else this._LName = "";
    }

    public String get_FName() {
        return _FName;
    }

    public void set_FName(String _FName) {
        if(CheckIsDataCorrect(_FName,3))
            this._FName = _FName;
        else
            this._FName = "";
    }

    public String get_Username() {
        return _Username;
    }

    public void set_Username(String _Username) {

        if(CheckIsDataCorrect(_Username,3))
            this._Username = _Username;
        else this._Username = "";
    }

    public String get_PhoneNo() {
        return _PhoneNo;
    }

    public void set_PhoneNo(String _PhoneNo)
    {
        if(CheckPhoneNoCorrect(_PhoneNo))
            this._PhoneNo = _PhoneNo;
        else
            this._PhoneNo = "";
    }

    public Integer get_RoleId() {
        return _RoleId;
    }

    public void set_RoleId(int _RoleId) {
        this._RoleId = _RoleId;
    }

    public Integer get_IsActive() {
        return _IsActive;
    }

    public void set_IsActive(int _IsActive) {
        this._IsActive = _IsActive;
    }

    public Integer get_AdressId() {
        return _AdressId;
    }

    public void set_AdressId(Integer _AdressId) {
        this._AdressId = _AdressId;
    }

    public Integer get_ClassId() {
        return _ClassId;
    }

    public void set_ClassId(Integer _ClassId) {
        this._ClassId = _ClassId;
    }

    public String get_Password() {
        return _Password;
    }

    public void set_Password(String _Password) {
        if(CheckIsDataCorrect(_Password,4))
            this._Password = _Password;
        else
            this._Password = "";
    }

    public Integer get_IsLoggedIn() {
        return _IsLoggedIn;
    }

    public void set_IsLoggedIn(Integer _IsLoggedIn) {
        this._IsLoggedIn = _IsLoggedIn;
    }

    public String get_ExternAppId() {
        return _ExternAppId;
    }

    public void set_ExternAppId(String _ExternAppId) {
        this._ExternAppId = _ExternAppId;
    }


    boolean CheckIsDataCorrect(String str, Integer length)
    {
        if(str!= null && str.trim().length() >= length && !str.contains(" "))
            return true;
        return false;
    }

    boolean CheckPhoneNoCorrect(String str)
    {
        if(str!= null && str.trim().length() == 9 && !str.contains(" "))
        {
            return true;
        }
        return false;
    }
}