public ActionResult AddProduct() { string Action = string.Empty; if (Request.Form.ContainsKey("hidActionSaveUpdate")) { Action = Request.Form["hidActionSaveUpdate"].ToString(); } int ProdCatId = 0; if (Request.Form.ContainsKey("ddlCategory")) { ProdCatId = Convert.ToInt32(Request.Form["ddlCategory"].ToString()); } string ProdName = string.Empty; if (Request.Form.ContainsKey("txtProductName")) { ProdName = Request.Form["txtProductName"].ToString(); } string ProdDescription = string.Empty; if (Request.Form.ContainsKey("txtProductDesc")) { ProdDescription = Request.Form["txtProductDesc"].ToString(); } APICall.CommomResponse objData = new APICall.CommomResponse(); objData.message = "NO ACTION"; if (Action.Equals("Save")) { string send_data = "{\n \"ProdCatId\": " + ProdCatId + ",\n \"ProdName\": \"" + ProdName + "\",\n \"ProdName\": \"" + ProdName + "\",\n \"ProdDescription\": \"" + ProdDescription + "\"\n}"; APICall.APIData objAPIResult = APICall.CallPOST_PUTAPI(CommonConfig.GetAPIEndPoint + "Product", send_data, HttpMethod.Post); objData = JsonConvert.DeserializeObject <APICall.CommomResponse>(objAPIResult.apiResponseString); } if (Action.Equals("Update")) { int ProductId = 0; if (Request.Form.ContainsKey("hidPid")) { ProductId = Convert.ToInt32(Request.Form["hidPid"].ToString()); } string send_data = "{\n \"ProductId\": " + ProductId + ",\n\"ProdCatId\": " + ProdCatId + ",\n \"ProdName\": \"" + ProdName + "\",\n \"ProdName\": \"" + ProdName + "\",\n \"ProdDescription\": \"" + ProdDescription + "\"\n}"; APICall.APIData objAPIResult = APICall.CallPOST_PUTAPI(CommonConfig.GetAPIEndPoint + "Product", send_data, HttpMethod.Put); objData = JsonConvert.DeserializeObject <APICall.CommomResponse>(objAPIResult.apiResponseString); } TempData.Add("Message", objData.message); return(RedirectToAction("Index", "Home")); }
public string getProductCategory() { APICall.APIData objAPIResult = APICall.CallGETAPI(CommonConfig.GetAPIEndPoint + "ProductCategory"); return(objAPIResult.apiResponseString); }