private void FetchRecords() { using (var client = new HttpClient()) { client.BaseAddress = new Uri(System.Configuration.ConfigurationManager.AppSettings["uri"]); client.DefaultRequestHeaders.Accept.Clear(); client.DefaultRequestHeaders.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/json")); //GET Method //string api = "api/ItemRanges?filter={\"where\":{\"itmCode\":\"" + _PKey + "\"}}"; string api = "api/ItemSiteLists/" + _PKey; var response = client.GetAsync(api).Result; if (response.IsSuccessStatusCode) { var a = response.Content.ReadAsStringAsync().Result; MasterItemSiteLists masterItemSite = JsonConvert.DeserializeObject <MasterItemSiteLists>(a); txtSiteCode_Site.Disabled = true; txtSiteCode_Site.Value = masterItemSite.itemsiteCode; txtAddress_Site.Value = masterItemSite.itemsiteAddress; txtSiteDesc_Site.Value = masterItemSite.itemsiteDesc; txtPostCode_Site.Value = masterItemSite.itemsitePostcode; ddlSiteGroup.Value = masterItemSite.siteGroup + "-" + masterItemSite.siteGroupIdId; ddlCity.Value = masterItemSite.itemSiteCityIdId; ddlState.Value = masterItemSite.itemSiteStateIdId; ddlCountry.Value = masterItemSite.itemSiteCountryIdId; txtContact1_Site.Value = masterItemSite.itemsitePhone1; txtContact2_Site.Value = masterItemSite.itemsitePhone2; txtFax_Site.Value = masterItemSite.itemsiteFax; txtEMail_Site.Value = masterItemSite.itemsiteEmail; chkSalesActive_Site.Checked = masterItemSite.itemsiteIsactive; chkGstActive_Site.Checked = masterItemSite.siteIsGst; txtSiteAcCode_Site.Value = masterItemSite.accountCode; } else { Console.WriteLine("Internal server Error"); } } }
protected void Operation_Click(object sender, EventArgs e) { try { if (Validation()) { if (btn_AddSite.InnerText.Trim() == "Add") { using (var client = new HttpClient()) { MasterItemSiteLists p = new MasterItemSiteLists { itemsiteCode = txtSiteCode_Site.Value.ToString().Trim(), itemsiteDesc = txtSiteDesc_Site.Value.ToString().Trim(), itemsiteType = "", itemPurchasedept = "", itemsiteAddress = txtAddress_Site.Value.ToString().Trim(), itemsitePostcode = txtPostCode_Site.Value.ToString().Trim(), itemsiteCity = ddlCity.Value.ToString().Trim(), itemsiteState = ddlState.Value.ToString().Trim(), itemsiteCountry = ddlCountry.Value.ToString().Trim(), itemsitePhone1 = txtContact1_Site.Value.ToString().Trim(), itemsitePhone2 = txtContact2_Site.Value.ToString().Trim(), itemsiteFax = txtFax_Site.Value.ToString().Trim(), itemsiteEmail = txtEMail_Site.Value.ToString().Trim(), itemsiteUser = "", itemsiteDate = (DateTime.Now.Date), itemsiteTime = (DateTime.Now.Date), itemsiteIsactive = chkSalesActive_Site.Checked, itemsiteRefcode = "", siteGroup = ddlSiteGroup.Value.ToString().Trim(), siteIsGst = chkGstActive_Site.Checked, accountCode = txtSiteAcCode_Site.Value.ToString().Trim(), ratings = "", picPath = "", qrcode = "", systemlogMdplUpdate = true, sitedbconnectionurl = "" }; client.BaseAddress = new Uri(System.Configuration.ConfigurationManager.AppSettings["uri"]); client.DefaultRequestHeaders.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/json")); var post = client.PostAsJsonAsync <MasterItemSiteLists>("api/ItemSiteLists", p); post.Wait(); var response = post.Result; if (response.IsSuccessStatusCode) { oCommonEngine.SetAlert(this.Page, "Item Site List Save Successfully..!", Utilities.CommonEngine.MessageType.Success, Utilities.CommonEngine.MessageDuration.Short); } else { oCommonEngine.SetAlert(this.Page, response.StatusCode + "...!", Utilities.CommonEngine.MessageType.Error, Utilities.CommonEngine.MessageDuration.Short); } } } else { using (var client = new HttpClient()) { MasterItemSiteListsUpdate p = new MasterItemSiteListsUpdate { itemsiteId = Int32.Parse(_PKey), itemsiteCode = txtSiteCode_Site.Value.ToString().Trim(), itemsiteDesc = txtSiteDesc_Site.Value.ToString().Trim(), itemsiteType = "", itemPurchasedept = "", itemsiteAddress = txtAddress_Site.Value.ToString().Trim(), itemsitePostcode = txtPostCode_Site.Value.ToString().Trim(), itemsiteCity = ddlCity.Value.ToString().Trim(), itemsiteState = ddlState.Value.ToString().Trim(), itemsiteCountry = ddlCountry.Value.ToString().Trim(), itemsitePhone1 = txtContact1_Site.Value.ToString().Trim(), itemsitePhone2 = txtContact2_Site.Value.ToString().Trim(), itemsiteFax = txtFax_Site.Value.ToString().Trim(), itemsiteEmail = txtEMail_Site.Value.ToString().Trim(), itemsiteUser = "", itemsiteDate = (DateTime.Now.Date), itemsiteTime = (DateTime.Now.Date), itemsiteIsactive = chkSalesActive_Site.Checked, itemsiteRefcode = "", siteGroup = ddlSiteGroup.Value.ToString().Trim(), siteIsGst = chkGstActive_Site.Checked, accountCode = txtSiteAcCode_Site.Value.ToString().Trim(), ratings = "", picPath = "", qrcode = "", systemlogMdplUpdate = true, sitedbconnectionurl = "" }; client.BaseAddress = new Uri(System.Configuration.ConfigurationManager.AppSettings["uri"]); client.DefaultRequestHeaders.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/json")); var post = client.PutAsJsonAsync <MasterItemSiteListsUpdate>("api/ItemSiteLists", p); post.Wait(); var response = post.Result; if (response.IsSuccessStatusCode) { oCommonEngine.SetAlert(this.Page, "Item Site List Updated Successfully..!", Utilities.CommonEngine.MessageType.Success, Utilities.CommonEngine.MessageDuration.Short); } else { oCommonEngine.SetAlert(this.Page, response.StatusCode + "...!", Utilities.CommonEngine.MessageType.Error, Utilities.CommonEngine.MessageDuration.Short); } } } DataClear(); } //BindData(); //if (Validation()) //{ // oDT_General = oCommonEngine.ExecuteDataTable("EXEC [Operation_Masters] '" + strUserCode.ToString() + "','" + strSiteCode.ToString() + "','Corporate','" + btnOperation.InnerText.Trim() + "','" + oCommonEngine.GetXMLfromDataTable(oDT_General).ToString() + "'"); // if (btnOperation.InnerText.Trim() == "Add") // { // Session["AlertMessage"] = "Corporate: " + oDT_General.Rows[0][0].ToString() + " Created Sucessfully...!"; // Response.Redirect("CorporateMaster.aspx?PKey=" + txtCode_Corporate.Value.ToString().Trim() + ""); // } // else // { // Session["AlertMessage"] = "Corporate: " + txtCode_Corporate.Value.ToString().Trim() + " Updated Sucessfully...!"; // Response.Redirect("CorporateMaster.aspx?PKey=" + txtCode_Corporate.Value.ToString().Trim() + ""); // } //} } catch (Exception Ex) { oCommonEngine.SetAlert(this.Page, Ex.Message, Utilities.CommonEngine.MessageType.Error, Utilities.CommonEngine.MessageDuration.Short); } }