public void DownloadDeploymentCategories() { var restClient = new RestClient(TrackerUrl); var request = new RestRequest(Method.GET); request.AddParameter("cat", "all"); restClient.ExecuteAsync(request, response => { try { JToken job = JToken.Parse(response.Content); List<DeploymentCategory> deploymentcategories = new List<DeploymentCategory>(); foreach (JObject jvalue in job.Values()) { DeploymentCategory dpCategory = new DeploymentCategory() { id = (string)jvalue.SelectToken("id"), name = (string)jvalue.SelectToken("name") }; } DataDownloadComplete.Invoke(this, new DownloadCompleteArgs() { DownloadObject = deploymentcategories, Response = response }); } catch { DataDownloadCompleteWithError.Invoke(this, new DownloadCompleteArgs() { DownloadObject = new Error() { code = "", message = "Download of categories failed" }, Response = response }); } }); }
/// <summary> /// Save a DeploymentCategory /// </summary> /// <param name="dcat"></param> public void SaveDeploymentCategory(DeploymentCategory dcat) { if (getDeploymentCategory(dcat.id)==null) { db.DeploymentCategory.InsertOnSubmit(dcat); SaveChangesToDB(); } }