public void LoadCustomers() { SelectedCustomer = null; Customers.Clear(); CustomersGroup.Clear(); _restClient.Get <List <Model.Customer> >(Callback); }
public void WhenISearchFor(Table table) { Dictionary <string, string> dict = table.Rows.ToDictionary(r => r["Field"], r => r["Value"]); url = envSettings.BaseUrl + "customers/api/CustomerSearch/?" + dict["parameter1"] + "=" + CheckForSpaces(dict["parameter2"]); if (!string.IsNullOrEmpty(GetKey(dict, "parameter3"))) { url = url + "&" + dict["parameter3"] + "=" + CheckForSpaces(dict["parameter4"]); } if (!string.IsNullOrEmpty(GetKey(dict, "parameter5"))) { url = url + "&" + dict["parameter5"] + "=" + CheckForSpaces(dict["parameter6"]); } var maxTries = 6; var triesSoFar = 0; while (triesSoFar < maxTries) { triesSoFar++; response = RestHelper.Get(url, envSettings.TouchPointId, envSettings.SubscriptionKey); if (response.StatusCode == HttpStatusCode.OK) { break; } Console.WriteLine("Try" + triesSoFar + " of " + maxTries + " returned response " + response.StatusCode.ToString()); Thread.Sleep(1000); } }
private async void btnGet_Click(object sender, EventArgs e) { int id = Convert.ToInt32(txtId.Text); var response = await RestHelper.Get(id); Producto lst = JsonConvert.DeserializeObject <Producto>(response); /* */ List <Producto> listaTemp = new List <Producto>(); listaTemp.Add(lst); var nuevalista = listaTemp.Select(x => new { Id_Producto = x.idProducto, Nombre_Producto = x.nombreProducto, Stock_Producto = x.stockProducto, Stock_Minimo = x.stockMinimo, Categoria_Producto = x.unidad.nombreUnidadMedida }).ToList(); dataGridView1.DataSource = nuevalista; dataGridView1.Refresh(); //string url = "http://localhost:9090/api/productos"; //var json = new WebClient().DownloadString(url); //var m = JsonConvert.DeserializeObject<List<Producto>>(json); //dataGridView1.DataSource = m; }
public IHttpActionResult Get(string guid, int limit = 1000) { JavaScriptSerializer jss = new JavaScriptSerializer(); List <IActionEvent> events = new List <IActionEvent>(); try { Durados.Web.Mvc.View view = GetView("durados_Log"); int rowCount = -1; Dictionary <string, object>[] filterArray = new Dictionary <string, object>[2] { new Dictionary <string, object>() { { "fieldName", "Guid" }, { "operator", FilterOperandType.equals.ToString() }, { "value", guid } }, new Dictionary <string, object>() { { "fieldName", "LogType" }, { "operator", FilterOperandType.greaterThan.ToString() }, { "value", 501 } } }; Dictionary <string, object>[] sortArray = new Dictionary <string, object>[1] { new Dictionary <string, object>() { { "fieldName", "Time" }, { "order", "asc" } } }; var items = (Dictionary <string, object>)RestHelper.Get(view, false, false, 1, limit * 2 + 1, filterArray, null, sortArray, out rowCount, false, view_BeforeSelect, view_AfterSelect, false, false, false, false, null, true, false); if (rowCount > limit) { return(ResponseMessage(Request.CreateResponse(HttpStatusCode.PreconditionFailed, "Number of actions is more than " + limit))); } var data = (Dictionary <string, object>[])items["data"]; foreach (Dictionary <string, object> item in data) { var actionEventData = jss.Deserialize <Dictionary <string, object> >(item["FreeText"].ToString()); IActionEvent actionEvent = new ActionEvent((int)actionEventData["time"], (Event)Enum.Parse(typeof(Event), actionEventData["event"].ToString(), true), actionEventData["objectName"].ToString(), actionEventData["actionName"].ToString(), actionEventData["id"].ToString(), actionEventData["data"]); events.Add(actionEvent); } CallStackConverter callStackConverter = new CallStackConverter(); var result = callStackConverter.ChronologicalListToTree(events.OrderBy(e => e.Time).ToList()); if (result == null) { return(Ok(new { })); } return(Json(result, ViewHelpers.CamelCase)); } catch (Exception exception) { string eventsJson = jss.Serialize(events); Maps.Instance.DuradosMap.Logger.Log("", "", "", exception, 1, eventsJson); throw new BackAndApiUnexpectedResponseException(exception, this); } }
public virtual IHttpActionResult Get(string id) { try { Durados.Web.Mvc.View view = (Durados.Web.Mvc.View)Maps.Instance.DuradosMap.Database.Views[viewName]; if (view == null) { return(ResponseMessage(Request.CreateResponse(HttpStatusCode.NotFound, string.Format(Messages.ViewNameNotFound, viewName)))); } if (string.IsNullOrEmpty(id)) { return(ResponseMessage(Request.CreateResponse(HttpStatusCode.NotFound, Messages.IdIsMissing))); } if (!view.IsAllow()) { return(ResponseMessage(Request.CreateResponse(HttpStatusCode.Forbidden, Messages.ViewIsUnauthorized))); } var item = RestHelper.Get(view, id, false, view_BeforeSelect, view_AfterSelect, false, false, true); if (item == null) { return(ResponseMessage(Request.CreateResponse(HttpStatusCode.NotFound, string.Format(Messages.ItemWithIdNotFound, id, viewName)))); } return(Ok(item)); } catch (Exception exception) { throw new BackAndApiUnexpectedResponseException(exception, this); } }
public ActionResult Get(string name) { try { if (string.IsNullOrEmpty(name)) { return(new ViewNameWasNotSuppliedApiHttpException()); } View view = GetView(name); if (view == null) { return(new ViewNotFoundApiHttpException(name, Response)); } ConfigAccess ConfigAccess = new ConfigAccess(); var pk = ConfigAccess.GetViewPK(name, Map.GetConfigDatabase().ConnectionString); var item = RestHelper.Get(GetView("View"), pk, true, view_BeforeSelect, view_AfterSelect); Response.StatusCode = (int)HttpStatusCode.OK; return(Json(item, JsonRequestBehavior.AllowGet)); } catch (Exception exception) { return(new UnexpectedApiHttpException(exception, Response)); } }
public static List <Order> GetMyOrders(this AccountProfile profile, OrderType orderType) { string json = RestHelper.Get($"profile/{MarketManager.Instance.Account.InGameName}/orders", requireAuth: true).Content.Replace("\\", "/"); var orderConfig = ProfileOrders_QuickType.FromJson(json); return((orderType == OrderType.Buy) ? orderConfig.Payload.BuyOrders : orderConfig.Payload.SellOrders); }
public async Task <ActionResult> Search(string searchstring) { SearchResult model = new SearchResult() { }; if (ModelState.IsValid) { try { IRestResponse <SearchResult> searchResultsResponse = await RestHelper.Get <SearchResult>($"{_apiUrl}/phonebook/Search", new List <KeyValuePair <string, object> >() { new KeyValuePair <string, object>("searchstring", searchstring) }); //save the data to the database //add message to success TempData if (searchResultsResponse.IsSuccessful) { model = searchResultsResponse.Data; } } catch (Exception ex) { //log the error //issue saving the value } } else { } return(PartialView("_SearchResults", model)); }
public async Task <ActionResult> EditPhonebook(int id = 0) { PhoneBookModel model = new PhoneBookModel() { Entries = new List <EntryModel>() }; if (id == 0) { return(View(model)); } IRestResponse <PhoneBookModel> phonebookResponse = await RestHelper.Get <PhoneBookModel>($"{_apiUrl}/phonebook/getphonebookbyid", new List <KeyValuePair <string, object> >() { new KeyValuePair <string, object>("id", id) }); if (phonebookResponse.IsSuccessful) { model = phonebookResponse.Data; IRestResponse <IEnumerable <EntryModel> > entiresResponse = await RestHelper.Get <IEnumerable <EntryModel> >($"{_apiUrl}/phonebook/GetPhoneBookEntriesForPhoneBook", new List <KeyValuePair <string, object> >() { new KeyValuePair <string, object>("phoneId", id) }); if (entiresResponse.IsSuccessful) { model.Entries = entiresResponse.Data.ToList(); } } return(View(model)); }
public virtual IHttpActionResult Delete(string id) { try { View view = GetView(GetConfigViewName()); if (!IsAdmin()) { return(ResponseMessage(Request.CreateResponse(HttpStatusCode.Forbidden, Messages.ActionIsUnauthorized))); } var item = RestHelper.Get(view, id, true, view_BeforeSelect, view_AfterSelect, false, true); if (item == null) { return(ResponseMessage(Request.CreateResponse(HttpStatusCode.NotFound, string.Format(Messages.RuleNotFound)))); } view.Delete(id, view_BeforeDelete, view_AfterDeleteBeforeCommit, view_AfterDeleteAfterCommit); RefreshConfigCache(); return(Ok(new { __metadata = new { id = id } })); } catch (Exception exception) { throw new BackAndApiUnexpectedResponseException(exception, this); } }
public bool CheckNthOccupationReturnedForAlternateLabelMatch <T>(int n, IList <T> ncsData) where T : NcsEntity { IList <string> stringList = new List <string>(); // get nth occupation in ncs response string uri = ncsData[n - 1].uri; // make call to esco api to get alternate labels var response = RestHelper.Get(context.GetEscoApiBaseUrl() + "/resource/" + ncsData[0].GetType().Name.ToLower() + "? language=en&uri=" + uri); // confirm response was ok response.StatusCode.Should().Be(HttpStatusCode.OK); // parse the response data as json JObject escoResults = JObject.Parse(response.Content); //extract the data that we are interested in to a list IList <JToken> results = escoResults["alternativeLabel"]["en"].Children().ToList(); //ntext.ClearStringList(); Dictionary <string, string> escoAlternativeReferences = new Dictionary <string, string>(); //convert to a list of strings and store in test context foreach (JToken result in results) { string value = result.ToObject <string>(); stringList.Add(value); escoAlternativeReferences.Add(value, ""); } //convert to key only dictionary var ncsAlternateLabels = ncsData[n - 1].alternativeLabels.ToDictionary(x => x, x => ""); // confirm match with ncs api response data return(AreEqual(escoAlternativeReferences, ncsAlternateLabels)); }
public void GivenIMakeARequestToTheContentAPIToRetriveAllItems(string p0) { string uri = context.GetContentUri(context.ReplaceTokensInString(p0)); var response = RestHelper.Get(uri, context.GetContentApiHeaders()); context[constants.responseStatus] = response.StatusCode; context[constants.responseContent] = response.Content; context[constants.responseScope] = constants.resultSummary; }
public async Task <GetPaymentpoliciesResponse> getPaymentpoliciesService(string marketplaceId) { RestHelper helper = new RestHelper("sell/account/v1/payment_policy?marketplace_id={" + marketplaceId + "}"); var response = await helper.Get(); GetPaymentpoliciesResponse getPaymentpoliciesResponse = JsonConvert.DeserializeObject <GetPaymentpoliciesResponse>(response); return(getPaymentpoliciesResponse); }
public void GivenIMakeARequestToTheContentAPI() { string uri = context.GetLatestUri(); var response = RestHelper.Get(uri, context.GetTaxonomyApiHeaders()); context[constants.responseStatus] = response.StatusCode; context[constants.responseContent] = response.Content; context[constants.responseScope] = constants.resultSingle; }
public async Task <GetPaymentpolicyresponse> getPaymentpolicyService(string policyId) { RestHelper helper = new RestHelper(ApplicationConstants.PaymentPolicy_Url + policyId); var response = await helper.Get(); GetPaymentpolicyresponse getPaymentpolicyResponse = JsonConvert.DeserializeObject <GetPaymentpolicyresponse>(response); return(getPaymentpolicyResponse); }
public static List <Order> GetAllSellOrders(this ItemOverview marketItem, OnlineStatus onlineStatus) { var response = RestHelper.Get($"items/{marketItem.UrlName}/orders"); var config = ItemOrders_QuickType.FromJson(response.Content); var orders = config.Payload.Orders.GetOrdersOfType(OrderType.Sell, onlineStatus); return(orders); }
public async Task <GetPaymentpolicyByNameresponse> getPaymentPolicyByNameService(string name, string marketplaceId) { RestHelper helper = new RestHelper(ApplicationConstants.PaymentPolicy_Url + "get_by_policy_name?name=" + name + "&marketplace_id=" + marketplaceId); var response = await helper.Get(); GetPaymentpolicyByNameresponse getPaymentpolicyByNameresponse = JsonConvert.DeserializeObject <GetPaymentpolicyByNameresponse>(response); return(getPaymentpolicyByNameresponse); }
public virtual IHttpActionResult Post(bool?returnObject = null, string parameters = null) { try { Durados.Web.Mvc.View view = (Durados.Web.Mvc.View)Maps.Instance.DuradosMap.Database.Views[viewName]; if (view == null) { return(ResponseMessage(Request.CreateResponse(HttpStatusCode.NotFound, string.Format(Messages.ViewNameNotFound, viewName)))); } if (!view.IsCreatable() && !view.IsDuplicatable()) { return(ResponseMessage(Request.CreateResponse(HttpStatusCode.Forbidden, Messages.ActionIsUnauthorized))); } string json = System.Web.HttpContext.Current.Server.UrlDecode(Request.Content.ReadAsStringAsync().Result.Replace("%22", "%2522").Replace("%2B", "%252B").Replace("+", "%2B")); Dictionary <string, object>[] values = GetParameters(parameters, view, json); string pk = view.Create(values, false, view_BeforeCreate, view_BeforeCreateInDatabase, view_AfterCreateBeforeCommit, view_AfterCreateAfterCommit, true); string[] pkArray = pk.Split(';'); int pkArrayLength = pkArray.Length; if (returnObject.HasValue && returnObject.Value && pkArrayLength == 1) { var item = RestHelper.Get(view, pk, false, view_BeforeSelect, view_AfterSelect); return(Ok(item)); } else if (returnObject.HasValue && returnObject.Value && pkArrayLength > 1 && pkArrayLength <= 100) { List <Dictionary <string, object> > data = new List <Dictionary <string, object> >(); foreach (string key in pkArray) { var item = RestHelper.Get(view, key, false, view_BeforeSelect, view_AfterSelect); data.Add(item); } Dictionary <string, object> items = new Dictionary <string, object>(); items.Add("totalRows", pkArrayLength); items.Add("data", data.ToArray()); return(Ok(items)); } object id = pk; if (pkArrayLength > 1) { id = pkArray; } return(Ok(new { __metadata = new { id = id } })); } catch (Exception exception) { throw new BackAndApiUnexpectedResponseException(exception, this); } }
public string CreateUserUpdate(string UserName, string Password, string UserID, string ClientApplicationID) { try { using (_helpers = new RestHelper()) { return(_helpers.Get(string.Format("{0}{1}{2}{3}{4}", _authenticationUrl, string.Concat("CreateUserUpdate?UserName="******"&Password="******"&ClientApplicationID=", ClientApplicationID), string.Concat("&UserID=", UserID)))); } } catch (Exception ex) { throw ex; } }
public string InsertEventLogError(string UserName, string Password, string Description) { try { using (_helpers = new RestHelper()) { return(_helpers.Get(string.Format("{0}{1}{2}{3}", _authenticationUrl, string.Concat("InsertEventLogError?UserName="******"&Password="******"&Description=", Description)))); } } catch (Exception ex) { throw ex; } }
private AutheticationObject DNNUserAuthentication(Guid ApplicationID, string UserName, string Password) { try { using (_authentication = new RestHelper <AutheticationObject>()) { return(_authentication.Get(string.Format("{0}{1}{2}{3}", _authenticationUrl, string.Concat("ApplicationAuthetication?ApplicationUniqueID=", ApplicationID), string.Concat("&UserName="******"&Password=", Password)))); } } catch (Exception ex) { throw ex; } }
public ApplicationCredentialObject DNNApplicationCredentials(Guid ApplicationID, string UserName, string Password, string Addtional) { try { using (_applicationCredentialObject = new RestHelper <ApplicationCredentialObject>()) { return(_applicationCredentialObject.Get(string.Format("{0}{1}{2}{3}{4}", _authenticationUrl, string.Concat("GetApplicationCredentials?ApplicationUniqueID=", ApplicationID), string.Concat("&UserName="******"&Password="******"&Addtional=", Addtional)))); } } catch (Exception ex) { throw ex; } }
public ApplicationCredentialObject DNNApplicationCredentials(Guid ApplicationID) { try { using (_applicationCredentialObject = new RestHelper <ApplicationCredentialObject>()) { return(_applicationCredentialObject.Get(string.Format("{0}{1}", _authenticationUrl, string.Concat("GetApplicationCredentialsNotAuthentication?ApplicationUniqueID=", ApplicationID)))); } } catch (Exception ex) { throw ex; } }
public string ClientSMSInsert(Guid ApplicationUniqueID, string UserName, string Password, string Number, string MessageText, string ResultString) { try { using (_helpers = new RestHelper()) { return(_helpers.Get(string.Format("{0}{1}{2}{3}{4}{5}{6}", _authenticationUrl, string.Concat("InsertSMSRecord?ApplicationUniqueID=", ApplicationUniqueID), string.Concat("&UserName="******"&Password="******"&Number=", Number), string.Concat("&MessageText=", MessageText), string.Concat("&ResultString=", ResultString)))); } } catch (Exception ex) { throw ex; } }
public string ClientSMSInsert(Guid ApplicationUniqueID, string Number, string MessageText, string ResultString) { try { using (_helpers = new RestHelper()) { return(_helpers.Get(string.Format("{0}{1}{2}{3}{4}{5}", _authenticationUrl, string.Concat("InsertSMSRecordApplicationUniqueID?ApplicationUniqueID=", ApplicationUniqueID), string.Concat("&Number=", Number), string.Concat("&MessageText=", MessageText), string.Concat("&ResultString=", ResultString), string.Concat("&Addtional=", string.Empty)))); } } catch (Exception ex) { throw ex; } }
private async void FillData(Guid Id) { string jsonString = await RestHelper.Get(Id); var jsonObject = JObject.Parse(jsonString); txtNome.Text = jsonObject["nome"].ToString(); txtSobrenome.Text = jsonObject["sobrenome"].ToString(); txtTelefone.Text = jsonObject["telefone"].ToString(); }
public ActionResult Get(string name, string pk, bool?deep, bool?withSelectOptions, int?pageNumber, int?pageSize, string filter, string sort, bool descriptive = true) { try { if (string.IsNullOrEmpty(name)) { return(new ViewNameWasNotSuppliedApiHttpException()); } View view = GetView(name); if (view == null) { return(new ViewNotFoundApiHttpException(name, Response)); } if (!string.IsNullOrEmpty(pk)) { var item = RestHelper.Get(view, pk, deep ?? false, view_BeforeSelect, view_AfterSelect, descriptive); if (item == null) { return(new ItemNotFoundInViewApiHttpException(pk, name, Response)); } Response.StatusCode = (int)HttpStatusCode.OK; return(Json(item, JsonRequestBehavior.AllowGet)); } else { int rowCount = 0; Dictionary <string, object>[] filterArray = null; if (!string.IsNullOrEmpty(filter)) { filterArray = JsonConverter.DeserializeArray(filter); } Dictionary <string, object>[] sortArray = null; if (!string.IsNullOrEmpty(sort)) { sortArray = JsonConverter.DeserializeArray(sort); } var items = RestHelper.Get(view, withSelectOptions ?? false, false, pageNumber ?? 1, pageSize ?? 20, filterArray, null, sortArray, out rowCount, false, view_BeforeSelect, view_AfterSelect); Response.StatusCode = (int)HttpStatusCode.OK; return(Json(items, JsonRequestBehavior.AllowGet)); } } catch (Exception exception) { return(UnexpectedException(exception, Response)); } }
public async Task <GetCategoryTreeResponse> GetCategoryTree(GetCategoryTreeRequest request) { string url = "commerce/taxonomy/v1_beta/category_tree/{0}"; RestHelper helper = new RestHelper(string.Format(url, request.category_tree_id)); var response = await helper.Get(); GetCategoryTreeResponse serlializedResponse = JsonConvert.DeserializeObject <GetCategoryTreeResponse>(response); return(serlializedResponse); }
public async Task <GetItemAspectsForCategoryResponse> GetItemAspectsForCategory(GetItemAspectsForCategoryRequest request) { string url = "commerce/taxonomy/v1_beta/category_tree/{0}/get_item_aspects_for_category?category_id ={1}"; RestHelper helper = new RestHelper(string.Format(url, request.category_tree_id, request.category_id)); var response = await helper.Get(); GetItemAspectsForCategoryResponse serlializedResponse = JsonConvert.DeserializeObject <GetItemAspectsForCategoryResponse>(response); return(serlializedResponse); }
public async Task <GetDefaultCategoryTreeIdResponse> GetDefaultCategoryTreeId(GetDefaultCategoryTreeIdRequest request) { string url = "commerce/taxonomy/v1_beta/get_default_category_tree_id?marketplace_id={0}"; RestHelper helper = new RestHelper(string.Format(url, request.marketplace_id)); var response = await helper.Get(); GetDefaultCategoryTreeIdResponse getFulfillmentPolicyByNameResponse = JsonConvert.DeserializeObject <GetDefaultCategoryTreeIdResponse>(response); return(getFulfillmentPolicyByNameResponse); }