示例#1
0
        public bool Login(int id, string pass, RezervareObserver obs)
        {
            Agent l = repoAgent.find(id);

            if (l == null)
            {
                return(false);
            }
            if (l.Password == pass)
            {
                observers.Add(obs);
                return(true);
            }

            return(false);
        }
示例#2
0
        public bool Login(int id, string pass, RezervareObserver obs)
        {
            initializeConnection();
            Agent userDTO = new Agent(id, pass);

            sendRequest(new LoginRequest(userDTO));
            Response res = readResponse();

            if (res is OkResponse)
            {
                this.client = obs;
                return(true);
            }
            if (res is ErrorResponse)
            {
                ErrorResponse err = (ErrorResponse)res;
                closeConnection();
                throw new Exception(err.Message);
            }
            return(false);
        }