public void AddParameter_WithValue_AddsValue() { client.AddParameter("key", "value"); Assert.Equal(1, client.callParameters.Count); Assert.Equal(true, client.callParameters.ContainsKey("key")); Assert.Equal("value", client.callParameters["key"]); }
public async Task <List <Ocupability> > GetOcupabilityLevelAsync(string supervisorId, CancellationToken cancellationToken = new CancellationToken()) { _apiClient.AddParameter("supervisorId", supervisorId); var response = await _apiClient.ExecuteGet <List <Ocupability> >(Constants.FesaApi.Ocupability); _apiClient.CleanParameters(); return((List <Ocupability>)response.Content); }
public async Task <UserModel> Login(string username, string password) { UserModel item = null; try { _apiClient.AddParameter("username", username); _apiClient.AddParameter("userpassword", password); var response = await _apiClient.ExecutePost <UserModel>("Users/Login"); if (response == null || response.Status != System.Net.HttpStatusCode.OK) { return(null); } item = (UserModel)response.Content; } catch (Exception e) { string m = e.Message; } return(item); }
public async Task <bool> SendAssignmentCompletionToClientAsync(string assignmentId, CancellationToken cancellationToken = new CancellationToken()) { _apiClient.AddParameter("assignmentId", assignmentId); var response = await _apiClient.ExecutePost(Constants.FesaApi.AssignmentEnded); return(response.Status != HttpStatusCode.OK); }
public async Task <UserViewModel> Login(string vUsername, string vPassword) { UserViewModel vResult = new UserViewModel(); try { _vApiClient.AddParameter("username", vUsername); _vApiClient.AddParameter("password", vPassword); var vResponse = await _vApiClient.ExecutePost <ClientResponseViewModel>("account"); if (vResponse == null || vResponse.Status != System.Net.HttpStatusCode.OK) { return(null); } ClientResponseViewModel vClientResponse = (ClientResponseViewModel)vResponse.Content; if (vClientResponse.Result == "False") { vResult = null; } else { IEnumerable <UserViewModel> vListUsers = JsonConvert.DeserializeObject <IEnumerable <UserViewModel> >(vClientResponse.Result); if (vListUsers != null && vListUsers.Count() > 0) { vResult = vListUsers.FirstOrDefault(); } else { vResult = null; } } } catch (Exception) { vResult = null; } return(vResult); }
public async Task <PaymentViewModel> SearchPay(PaymentSearchViewModel valPaymentSearch) { PaymentViewModel vResult = null; try { _vApiClient.AddParameter("IdPayment", valPaymentSearch.IdPayment); _vApiClient.AddParameter("IdLanguage", valPaymentSearch.IdLanguage); var vResponse = await _vApiClient.ExecuteGetWithJson <ClientResponseViewModel>("payment", valPaymentSearch); if (vResponse == null) { return(vResult); } if (vResponse.Status == HttpStatusCode.OK) { var vClientResponse = (ClientResponseViewModel)vResponse.Content; vResult = JsonConvert.DeserializeObject <PaymentViewModel>(vClientResponse.Result); } } catch (Exception ex) { string vMessage = ex.Message; vResult = null; } return(vResult); }
public async Task <AssignmentModel> GetOtAsync(string idOT, string idUser) { AssignmentModel Result = null; try { _apiClient.AddParameter("Id", idOT); _apiClient.AddParameter("userId", idUser); var response = await _apiClient.ExecutePost <ResponseAssignment>("Assignments/GetDetailOT"); Result = response.Content.Assignment; } catch (Exception e) { string m = e.Message; } return(Result); }
public async Task <User> LoginAsync(string userName, string password, CancellationToken cancellationToken = new CancellationToken()) { _apiClient.AddParameter("userName", userName); _apiClient.AddParameter("userPassword", password); var response = await _apiClient.ExecutePost <User>(Constants.FesaApi.LoginMethod); _apiClient.CleanParameters(); if (response.Status != HttpStatusCode.OK || response.Content == null) { return(null); } var user = (User)response.Content; await Database.Connection.InsertOrReplaceAsync(user, cancellationToken); return(user); }