public static void EditAddDeptMasterData(string itmCode, string itmDesc, bool itmStatus, string itmSeq, bool allowcashsales, bool itmShowonsales, bool isfirsttrial, bool isVoucher, bool isPrepaid, bool isRetailproduct, bool isSalonproduct, bool isPackage, bool isService, bool isCompound, string validityPeriod, string validityFrom, string validityTo, string siteCode) { using (var client = new HttpClient()) { deptMasterInput p = new deptMasterInput { itmCode = itmCode, itmDesc = itmDesc, itmStatus = itmStatus, itmSeq = itmSeq, allowcashsales = allowcashsales, itmShowonsales = itmShowonsales, isfirsttrial = isfirsttrial, isVoucher = isVoucher, isPrepaid = isPrepaid, isRetailproduct = isRetailproduct, isSalonproduct = isSalonproduct, isPackage = isPackage, isService = isService, isCompound = isCompound, validityPeriod = validityPeriod, vilidityFromDate = validityFrom, vilidityToDate = validityTo }; 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 <deptMasterInput>("api/ItemDepts/update?[where][itmCode]=" + itmCode + "", p); post.Wait(); var response = post.Result; System.Net.ServicePointManager.Expect100Continue = false; if (response.IsSuccessStatusCode) { var errorMessage = response.Content.ReadAsStringAsync().Result; Console.Write("Success"); } else { var errorMessage = response.Content.ReadAsStringAsync().Result; Console.Write("Error"); } } }
public static void AddDeptMasterData(string itmCode, string itmDesc, bool itmStatus, string itmSeq, bool allowcashsales, bool itmShowonsales, bool isfirsttrial, bool isVoucher, bool isPrepaid, bool isRetailproduct, bool isSalonproduct, bool isPackage, bool isService, bool isCompound, string validityPeriod, string validityFrom, string validityTo, string siteCode) { if (string.IsNullOrEmpty(siteCode)) { siteCode = "HQ"; } using (var client = new HttpClient()) { deptMasterInput p = new deptMasterInput { itmCode = itmCode, itmDesc = itmDesc, itmStatus = itmStatus, itmSeq = itmSeq, allowcashsales = allowcashsales, itmShowonsales = itmShowonsales, isfirsttrial = isfirsttrial, isVoucher = isVoucher, isPrepaid = isPrepaid, isRetailproduct = isRetailproduct, isSalonproduct = isSalonproduct, isPackage = isPackage, isService = isService, isCompound = isCompound, validityPeriod = validityPeriod, vilidityFromDate = validityFrom, vilidityToDate = validityTo }; 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 <deptMasterInput>("api/ItemDepts", p); post.Wait(); var response = post.Result; System.Net.ServicePointManager.Expect100Continue = false; if (response.IsSuccessStatusCode) { int Newcontrol = int.Parse(itmCode); int NewcontrolNo = Newcontrol + 1; ControlNosUpdate c = new ControlNosUpdate { controldescription = "DEPT CODE", sitecode = siteCode, controlnumber = Convert.ToString(NewcontrolNo) }; string api = "api/ControlNos/updatecontrol"; post = client.PostAsJsonAsync <ControlNosUpdate>(api, c); post.Wait(); response = post.Result; if (response.IsSuccessStatusCode) { Console.Write("Success"); } } else { throw new Exception("An Error has occured with Error Code.Please contact support team"); var errorMessage = response.Content.ReadAsStringAsync().Result; Console.Write("Error"); } } }