Exemple #1
0
 public void Logout(Employee employee, IObserver client)
 {
     sendRequest(new LogoutRequest(employee));
     ObjectResponseProtocol.Response response = readResponse();
     closeConnection();
     if (response is ObjectResponseProtocol.ErrorResponse)
     {
         ObjectResponseProtocol.ErrorResponse error = (ObjectResponseProtocol.ErrorResponse)response;
         throw new ValidationException(error.Message);
     }
 }
Exemple #2
0
        public List <ChildDTO> GetAllChildren()
        {
            sendRequest(new GetAllChildrenRequest());
            ObjectResponseProtocol.Response response = readResponse();
            if (response is ObjectResponseProtocol.ErrorResponse)
            {
                ObjectResponseProtocol.ErrorResponse error = (ObjectResponseProtocol.ErrorResponse)response;
                throw new ValidationException(error.Message);
            }

            ObjectResponseProtocol.GetAllChildrenResponse resp =
                (ObjectResponseProtocol.GetAllChildrenResponse)response;
            return(resp.Children);
        }
Exemple #3
0
        public Child RegisterChild(string name, int age, string challenge1, string challenge2)
        {
            RegistrationDTO registration = new RegistrationDTO(name, age, challenge1, challenge2);

            sendRequest(new RegisterChildRequest(registration));
            ObjectResponseProtocol.Response response = readResponse();
            if (response is ObjectResponseProtocol.ErrorResponse)
            {
                ObjectResponseProtocol.ErrorResponse error = (ObjectResponseProtocol.ErrorResponse)response;
                throw new ValidationException(error.Message);
            }

            ObjectResponseProtocol.RegisteredChildResponse resp = (ObjectResponseProtocol.RegisteredChildResponse)response;
            return(resp.Child);
        }
Exemple #4
0
        public Challenge GetChallengeByProperties(int minimumAge, int maximumAge, string name)
        {
            Challenge challenge = new Challenge(minimumAge, maximumAge, name);

            sendRequest(new GetChallengeByPropertiesRequest(challenge));
            ObjectResponseProtocol.Response response = readResponse();
            if (response is ObjectResponseProtocol.ErrorResponse)
            {
                ObjectResponseProtocol.ErrorResponse error = (ObjectResponseProtocol.ErrorResponse)response;
                throw new ValidationException(error.Message);
            }

            ObjectResponseProtocol.GetChallengeByPropertiesResponse resp =
                (ObjectResponseProtocol.GetChallengeByPropertiesResponse)response;
            return(resp.Challenge);
        }
Exemple #5
0
        public Employee RegisterEmployee(string username, string password)
        {
            initializeConnection();
            Employee employee = new Employee(username, password);

            sendRequest(new RegisterRequest(employee));
            ObjectResponseProtocol.Response response = readResponse();
            if (response is ObjectResponseProtocol.ErrorResponse)
            {
                ObjectResponseProtocol.ErrorResponse error = (ObjectResponseProtocol.ErrorResponse)response;
                closeConnection();
                throw new ValidationException(error.Message);
            }

            ObjectResponseProtocol.RegisteredResponse resp = (ObjectResponseProtocol.RegisteredResponse)response;
            closeConnection();
            return(resp.Employee);
        }
Exemple #6
0
        public virtual Employee LoginEmployee(string username, string password, IObserver client)
        {
            initializeConnection();
            Employee employee = new Employee(username, password);

            sendRequest(new LoginRequest(employee));
            ObjectResponseProtocol.Response response = readResponse();
            if (response is ObjectResponseProtocol.LoggedReponse)
            {
                this.client = client;
            }

            if (response is ObjectResponseProtocol.ErrorResponse)
            {
                ObjectResponseProtocol.ErrorResponse error = (ObjectResponseProtocol.ErrorResponse)response;
                closeConnection();
                throw new ValidationException(error.Message);
            }

            ObjectResponseProtocol.LoggedReponse resp = (ObjectResponseProtocol.LoggedReponse)response;
            return(resp.Employee);
        }