public async Task <RegisterDataDTO> RegisterUser(string[] parameters) { const string registrationEndpoint = BaseUrl + RequesterUrlConstants.RegistrationPath; var email = parameters[0]; var password = parameters[1]; var confirmPassword = parameters[2]; var content = new FormUrlEncodedContent(new[] { new KeyValuePair <string, string>("email", email), new KeyValuePair <string, string>("password", password), new KeyValuePair <string, string>("confirmPassword", confirmPassword) }); var response = await this.httpClient.PostAsync(registrationEndpoint, content); await this.ValiadteResponse(response); RegisterDataDTO registerData = new RegisterDataDTO { Email = email }; return(registerData); }
public async Task<RegisterDataDTO> RegisterUser(string[] parameters) { const string registrationEndpoint = BaseUrl + RequesterUrlConstants.RegistrationPath; var email = parameters[0]; var password = parameters[1]; var confirmPassword = parameters[2]; var content = new FormUrlEncodedContent(new[] { new KeyValuePair<string, string>("email", email), new KeyValuePair<string, string>("password", password), new KeyValuePair<string, string>("confirmPassword", confirmPassword) }); var response = await this.httpClient.PostAsync(registrationEndpoint, content); await this.ValiadteResponse(response); RegisterDataDTO registerData = new RegisterDataDTO { Email = email }; return registerData; }
public async override void Execute(string[] parameters) { try { RegisterDataDTO registerData = await this.GameEngine.Requester.RegisterUser(parameters); string formattedResult = string.Format(MessageConstants.SuccessfullyRegisteredUser, registerData.Email); this.Print(string.Format(" -{0}", formattedResult)); } catch (ApiException ex) { foreach (var error in ex.Errors) { this.Print(string.Format(MessageConstants.ErrorMessage, error)); } } catch (IndexOutOfRangeException ex) { this.Print(string.Format(MessageConstants.ErrorMessage, ex.Message)); } }