public void GetFilteredList() { DynamicsQuery query = new DynamicsQuery() { Table = DynamicsTables.Systemuser, Filters = new List <Filter>() { new Filter() { Field = nameof(SystemUser.firstname), Operator = FilterOperator.EqualsOperator, Value = FirstNameAnswer }, new Filter { Field = nameof(SystemUser.lastname), Operator = FilterOperator.EqualsOperator, Value = LastNameAnswer, GlobalOperator = FilterOperator.Or } } }; Task <DynamicsResponse <ICollection <SystemUser> > > task = HttpFunctions.GetAsync <DynamicsResponse <ICollection <SystemUser> > >(connector.GetClient(), query.GetPath()); DynamicsResponse <ICollection <SystemUser> > answer = task.GetAwaiter().GetResult(); Assert.IsTrue(answer != null); Assert.IsTrue(answer.value.Count > 0); Assert.IsTrue(answer.value.First().firstname.Equals(FirstNameAnswer) && answer.value.First().lastname.Equals(LastNameAnswer)); }
private static async Task <string> CreateCaseAction(IConfiguration configuration, ApplicationFormModel model) { HttpClient httpClient = null; try { var application = model.ToVsdVictimsModel(); JsonSerializerSettings settings = new JsonSerializerSettings(); settings.NullValueHandling = NullValueHandling.Ignore; var applicationJson = JsonConvert.SerializeObject(application, settings); applicationJson = applicationJson.Replace("odatatype", "@odata.type"); // Get results into the tuple var endpointAction = "vsd_CreateCVAPClaim"; var tuple = await GetDynamicsHttpClientNew(configuration, applicationJson, endpointAction); string tempResult = tuple.Item1.ToString(); DynamicsResponse dynamicsResponse = new DynamicsResponse(); dynamicsResponse.IsSuccess = (tempResult == "200"); // Only return true if we get a 200 back from the server dynamicsResponse.Result = tempResult; dynamicsResponse.odatacontext = tuple.Item2.ToString(); return(dynamicsResponse.odatacontext); } finally { if (httpClient != null) { httpClient.Dispose(); } } }
public void GetList() { DynamicsQuery query = new DynamicsQuery { Table = DynamicsTables.Organization }; Task <DynamicsResponse <ICollection <Organization> > > task = HttpFunctions.GetAsync <DynamicsResponse <ICollection <Organization> > >(connector.GetClient(), query.GetPath()); DynamicsResponse <ICollection <Organization> > answer = task.GetAwaiter().GetResult(); Assert.IsTrue(answer != null); Assert.IsTrue(answer.value.Count > 0); }
private static async Task <string> CallDynamicsWithCornetData(IConfiguration configuration, CornetTransaction model) { Console.WriteLine(DateTime.Now + " In CallDynamicsWithCornetData"); HttpClient httpClient = null; try { var cornetData = model.ToCornetDynamicsModel(); JsonSerializerSettings settings = new JsonSerializerSettings(); settings.NullValueHandling = NullValueHandling.Ignore; var cornetJson = JsonConvert.SerializeObject(cornetData, settings); cornetJson = cornetJson.Replace("odatatype", "@odata.type"); // Get results into the tuple var endpointAction = "vsd_CreateCORNETNotifications"; Console.WriteLine(DateTime.Now + " Set endpoint " + endpointAction); var tuple = await GetDynamicsHttpClientNew(configuration, cornetJson, endpointAction); Console.WriteLine(DateTime.Now + " Got result from Dynamics"); string tempResult = tuple.Item1.ToString(); string tempJson = tuple.Item3.ToString(); tempJson = tempJson.Replace("@odata.context", "oDataContext"); DynamicsResponseModel deserializeJson = JsonConvert.DeserializeObject <DynamicsResponseModel>(tempJson); DynamicsResponse dynamicsResponse = new DynamicsResponse(); dynamicsResponse.IsSuccess = deserializeJson.IsSuccess; dynamicsResponse.Result = deserializeJson.Result; if (dynamicsResponse.Result == null) { dynamicsResponse.odatacontext = tempJson; } else { dynamicsResponse.odatacontext = dynamicsResponse.Result; } Console.WriteLine(DateTime.Now + " Return results from Dynamics"); return(dynamicsResponse.odatacontext); } finally { if (httpClient != null) { httpClient.Dispose(); } } }
public void GetLimitedList() { DynamicsQuery query = new DynamicsQuery { Table = DynamicsTables.Systemuser, Top = 5 }; Task <DynamicsResponse <ICollection <SystemUser> > > task = HttpFunctions.GetAsync <DynamicsResponse <ICollection <SystemUser> > >(connector.GetClient(), query.GetPath()); DynamicsResponse <ICollection <SystemUser> > answer = task.GetAwaiter().GetResult(); Assert.IsTrue(answer != null); Assert.IsTrue(answer.value.Count == 5); }
private static async Task <string> CreateOffenderRestitutionAction(IConfiguration configuration, OffenderRestitutionFormModel model) { HttpClient httpClient = null; try { var offenderRestitution = model.ToOffenderRestitutionModel(); JsonSerializerSettings settings = new JsonSerializerSettings(); settings.NullValueHandling = NullValueHandling.Ignore; var offenderRestitutionJson = JsonConvert.SerializeObject(offenderRestitution, settings); offenderRestitutionJson = offenderRestitutionJson.Replace("odatatype", "@odata.type"); var endpointAction = "vsd_CreateRestitutionCase"; // TODO: Is this the same as Victim Restitution??? //httpClient = GetDynamicsHttpClient(configuration, endpointAction); var tuple = await GetDynamicsHttpClientNew(configuration, offenderRestitutionJson, endpointAction); //// THIS SHOULD BECOME A DYNAMICS MODEL //var dynamicsModel = model; // model.ToDynamicsModel(); //var invoiceJson = JsonConvert.SerializeObject(dynamicsModel); //HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Post, endpointAction); //request.Content = new StringContent(invoiceJson, Encoding.UTF8, "application/json"); //HttpResponseMessage response = await httpClient.SendAsync(request); //if (response.StatusCode == HttpStatusCode.OK) //{ // var jsonResult = response.Content.ReadAsStringAsync().Result; // return jsonResult; //} //return response.Content.ReadAsStringAsync().Result; string tempResult = tuple.Item1.ToString(); DynamicsResponse dynamicsResponse = new DynamicsResponse(); dynamicsResponse.IsSuccess = (tempResult == "200");// true; dynamicsResponse.Result = tempResult; dynamicsResponse.odatacontext = tuple.Item2.ToString(); return(dynamicsResponse.Result); } finally { if (httpClient != null) { httpClient.Dispose(); } } }
private static async Task <String> CreateInvoiceAction(IConfiguration configuration, CounsellorInvoiceFormModel model) { HttpClient httpClient = null; try { var invoiceModel = model.ToDynamicsModel(); JsonSerializerSettings settings = new JsonSerializerSettings(); settings.NullValueHandling = NullValueHandling.Ignore; var invoiceJson = JsonConvert.SerializeObject(invoiceModel, settings); invoiceJson = invoiceJson.Replace("odatatype", "@odata.type"); var endpointAction = "vsd_SubmitCounselorInvoice"; var tuple = await GetDynamicsHttpClientNew(configuration, invoiceJson, endpointAction); //HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Post, endpointAction); //request.Content = new StringContent(invoiceJson, Encoding.UTF8, "application/json"); //HttpResponseMessage response = await httpClient.SendAsync(request); //if (response.StatusCode == HttpStatusCode.OK) //{ // var jsonResult = response.Content.ReadAsStringAsync().Result; // return jsonResult; //} //return response.Content.ReadAsStringAsync().Result; string tempResult = tuple.Item1.ToString(); DynamicsResponse dynamicsResponse = new DynamicsResponse(); dynamicsResponse.IsSuccess = true; dynamicsResponse.Result = tempResult; dynamicsResponse.odatacontext = tuple.Item2.ToString(); return(dynamicsResponse.Result); } finally { if (httpClient != null) { httpClient.Dispose(); } } }