public async Task Endpoints_Framework_WebAPI_CustomerPost() { var responseData = new CustomerModel(); var urlCustomer = new ConfigurationManagerFull().AppSettingValue("MyWebService").AddLast("/Customer"); await this.Endpoints_Framework_WebAPI_CustomerPut(); var idToGet = Endpoints_Framework_for_WebApi.RecycleBin.Count() > 0 ? Endpoints_Framework_for_WebApi.RecycleBin[0] : TypeExtension.DefaultInteger; var url = new Uri(urlCustomer.AddLast("/") + idToGet.ToStringSafe()); var requestGet = new HttpRequestGet <CustomerModel>(url); responseData = await requestGet.SendAsync(); Assert.IsTrue(!responseData.IsNew); var testKey = Guid.NewGuid().ToString(); responseData.FirstName = responseData.FirstName.AddLast(testKey); var request = new HttpRequestPost <CustomerModel>(urlCustomer.TryParseUri(), responseData); responseData = await request.SendAsync(); Assert.IsTrue(!responseData.IsNew); Assert.IsTrue(responseData.FirstName.Contains(testKey)); }
public async Task Endpoints_WebApi_CustomerPost() { var responseData = new CustomerModel(); var urlCustomer = new ConfigurationManagerLocal().AppSettingValue("MyWebService").AddLast("/Customer"); await this.Endpoints_WebApi_CustomerPut(); var keyToGet = WebApiEndpointsTests.RecycleBin.Count() > 0 ? WebApiEndpointsTests.RecycleBin[0] : TypeExtension.DefaultGuid; var url = new Uri(urlCustomer.AddLast("/") + keyToGet.ToStringSafe()); var requestGet = new HttpRequestGet <CustomerModel>(url); responseData = await requestGet.SendAsync(); Assert.IsTrue(interfaceBreakingRelease || !responseData.IsNew); var testKey = RandomString.Next(); responseData.FirstName = responseData.FirstName.AddLast(testKey); var request = new HttpRequestPost <CustomerModel>(urlCustomer.TryParseUri(), responseData); responseData = await request.SendAsync(); Assert.IsTrue(interfaceBreakingRelease || !responseData.IsNew); Assert.IsTrue(interfaceBreakingRelease || responseData.FirstName.Contains(testKey)); }
public async Task Endpoints_Framework_WebAPI_CustomerPost() { var responseData = new Customer(); var urlCustomer = new ConfigurationManagerCore(ApplicationTypes.Native).AppSettingValue("MyWebService").AddLast("/Customer"); await this.Endpoints_Framework_WebAPI_CustomerPut(); var keyToGet = Endpoints_Framework_for_WebApi.RecycleBin.Count() > 0 ? Endpoints_Framework_for_WebApi.RecycleBin[0] : Guid.Empty; try { var url = new Uri(urlCustomer.AddLast("/") + keyToGet.ToStringSafe()); var requestGet = new HttpRequestGet <Customer>(url); responseData = await requestGet.SendAsync(); Assert.IsTrue(interfaceBreakingRelease || responseData != null); var testKey = RandomString.Next(); responseData.FirstName = responseData.FirstName.AddLast(testKey); var request = new HttpRequestPost <Customer>(urlCustomer.TryParseUri(), responseData); responseData = await request.SendAsync(); Assert.IsTrue(interfaceBreakingRelease || responseData != null); Assert.IsTrue(interfaceBreakingRelease || responseData.FirstName.Contains(testKey)); } catch (HttpRequestException ex) { Assert.IsTrue(ex.Message.Contains("No such host") || ex.Message.Contains("no data")); } }
/// <summary> /// Processes any page data via workflow /// </summary> public override async Task <WorkerResult> Process() { var returnValue = new WorkerResult(); var searchUri = new Uri(MyApplication.MyWebService.ToString().AddLast("/") + "CustomerSearch"); var request = new HttpRequestPost <CustomerModel, CustomerSearchModel>(MyViewModel.MyViewModelWebService, MyViewModel.MyModel.CastOrFill <CustomerModel>()); var returnData = request.SendAsync(); MyViewModel.MyModel = await MyViewModel.Sender.SendPostAsync <CustomerModel, CustomerSearchModel>(MyViewModel.MyViewModelWebService, MyViewModel.MyModel.CastOrFill <CustomerModel>()); BindModel(MyViewModel.MyModel); ListResults.ItemsSource = MyViewModel.MyModel.Results; if (MyViewModel.MyModel.Results.Count > 0) { OkCancel.TextResultMessage = "Customer matches listed below"; StackResults.Visibility = Visibility.Visible; } else { OkCancel.TextResultMessage = "No results found"; StackResults.Visibility = Visibility.Collapsed; } returnValue.ReturnData = MyViewModel.MyModel.Serialize(); return(returnValue); }
public async Task Customer_Cloud_CustomerPost() { CustomerModel responseData = new CustomerModel(); HttpRequestGet <CustomerModel> requestGet; HttpRequestPost <CustomerModel> request; int idToGet = TypeExtension.DefaultInteger; string urlRoot = new ConfigurationManagerFull().AppSettingValue("MyWebService"); string urlFull = TypeExtension.DefaultString; // Ensure customers exist await this.Customer_Cloud_CustomerPut(); idToGet = recycleBin.Count() > 0 ? recycleBin[0] : TypeExtension.DefaultInteger; // Call the cloud and get results urlFull = String.Format("{0}/{1}/{2}", urlRoot, "Customer", idToGet); requestGet = new HttpRequestGet <CustomerModel>(urlFull); responseData = await requestGet.SendAsync(); Assert.IsTrue(responseData.ID != TypeExtension.DefaultInteger, "Customer did not get."); Assert.IsTrue(responseData.Key != TypeExtension.DefaultGuid, "Customer did not get."); // Now edit the customer responseData.FirstName = responseData.FirstName + "Edited"; request = new HttpRequestPost <CustomerModel>(urlFull, responseData); responseData = await request.SendAsync(); Assert.IsTrue(responseData.ID != TypeExtension.DefaultInteger, "Customer did not get."); Assert.IsTrue(responseData.FirstName.Contains("Edited") == true, "Customer did not get."); }
/// <summary> /// Instantiates and transmits all data to the middle tier web service that will execute the workflow /// </summary> /// <returns></returns> public virtual async Task <TDataOut> SendPostAsync <TDataIn, TDataOut>(Uri fullUrl, TDataIn itemToSend) { var returnValue = default(TDataOut); var request = new HttpRequestPost <TDataIn, TDataOut>(fullUrl, itemToSend); OnSendBegin(request); returnValue = await request.SendAsync(); OnSendEnd(request); return(returnValue); }
/// <summary> /// Reads an item from the system /// Constrained to 1 item. Search using Queryflow /// </summary> /// <param name="item">item to update</param> /// <returns>Item from the system</returns> public async Task <TDto> UpdateAsync(TDto item) { TDto returnData; using (var client = new HttpRequestPost <TDto>(Uri, item)) { returnData = await client.SendAsync(); Response = client.Response; } return(await Task.Run(() => returnData)); }
public async Task Net_HttpRequestPost_SendAsync() { object dataOut = null; var configuration = ConfigurationManagerSafeTests.ConfigurationManagerSafeConstruct(); var request = new HttpRequestPost <object>(configuration.AppSettingValue("MyWebService") + "/HomeApi"); try { dataOut = await request.SendAsync(); Assert.IsTrue(request.Response.IsSuccessStatusCode); throw new WebException(); } catch (WebException) { Assert.IsTrue(dataOut != null); } finally { request.Dispose(); } }
public async Task Core_Net_HttpRequestPost_SendAsync() { object dataOut = null; var configuration = new ConfigurationManagerCore(ApplicationTypes.Native); var request = new HttpRequestPost <object>(configuration.AppSettingValue("MyWebService") + "/HomeApi"); try { dataOut = await request.SendAsync(); Assert.IsTrue(request.Response.IsSuccessStatusCode); throw new HttpRequestException(); } catch (HttpRequestException ex) { Assert.IsTrue(dataOut != null || ex.Message.Contains("No such host") || ex.Message.Contains("no data")); } finally { request.Dispose(); } }