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); } }
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); }
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); }
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); }
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); }
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); }