public IHttpActionResult GetKGPCategorySubCategoryWiseDataV2(KitchenGardenEntity objkgpList) { try { System.Net.Http.Headers.HttpRequestHeaders headers = this.Request.Headers; string x_StateName = string.Empty; string x_DistrictName = string.Empty; if (headers.Contains("state")) { x_StateName = headers.GetValues("state").First().ToLower(); } if (headers.Contains("district")) { x_DistrictName = headers.GetValues("district").First().ToLower(); } ReasonStatusBal _rsbal = new ReasonStatusBal(); // DataSet ds1 = new DataSet(); var ds1 = _rsbal.GetKGPCategorySubCategoryWiseData(objkgpList, x_StateName, x_DistrictName); ds1.Tables[0].TableName = "Product"; ds1.Tables[1].TableName = "Count"; return(Ok(new { ProductsApiReponse = ds1, Status = true })); } catch (Exception ex) { LogDal.ErrorLog(this.GetType().Name, MethodBase.GetCurrentMethod().Name, ex.Message, 0); return(Ok(new { ProductsApiReponse = "", Status = false })); } }
public DataSet GetKGPCategorySubCategoryWiseData(KitchenGardenEntity objkgpList, string StateName, string DistrictName) { List <KGPSubCategoryData> objlist = new List <KGPSubCategoryData>(); DataTable DTSubCategory = new DataTable(); DataSet ds1 = new DataSet(); if (objkgpList.KGPCategory.Count == 0 && objkgpList.KGP_CategoryId != null) { ds1 = _rsdal.GetCatSubCat(objkgpList.KGP_CategoryId); if (ds1.Tables.Count > 0) { if (ds1.Tables[0].Rows.Count > 0) { for (int i = 0; i < ds1.Tables[0].Rows.Count; i++) { objlist.Add(new KGPSubCategoryData { KGP_CategoryId = ds1.Tables[0].Rows[i]["KGP_CategoryId"] == DBNull.Value ? 0 : Convert.ToInt32(ds1.Tables[0].Rows[i]["KGP_CategoryId"]), KGP_SubCategoryId = ds1.Tables[0].Rows[i]["KGP_SubCategoryId"] == DBNull.Value ? 0 : Convert.ToInt32(ds1.Tables[0].Rows[i]["KGP_SubCategoryId"]), } ); } DTSubCategory = Helper.Helper.ToDataTable(objlist); } else { DTSubCategory.Columns.Add(new DataColumn("KGP_CategoryId", typeof(Int32))); DTSubCategory.Columns.Add(new DataColumn("KGP_SubCategoryId", typeof(Int32))); DataRow row = DTSubCategory.NewRow(); row["KGP_CategoryId"] = 0; row["KGP_SubCategoryId"] = 0; DTSubCategory.Rows.Add(row); } } } else if (objkgpList.KGPCategory != null) { foreach (var item in objkgpList.KGPCategory) { foreach (var item1 in item.KGPSubCategory) { KGPSubCategoryData obj = new KGPSubCategoryData(); obj.KGP_CategoryId = item1.KGP_CategoryId; obj.KGP_SubCategoryId = item1.KGP_SubCategoryId; objlist.Add(obj); } } DTSubCategory = Helper.Helper.ToDataTable(objlist); } else { DTSubCategory.Columns.Add(new DataColumn("KGP_CategoryId", typeof(Int32))); DTSubCategory.Columns.Add(new DataColumn("KGP_SubCategoryId", typeof(Int32))); DataRow row = DTSubCategory.NewRow(); row["KGP_CategoryId"] = 0; row["KGP_SubCategoryId"] = 0; DTSubCategory.Rows.Add(row); } //int id = _rsdal.GetFarmerIdByMobile(mobile); DataSet ds = new DataSet(); // DataTable DTCategory = Helper.Helper.ToDataTable(objkgpList.KGPCategory); ds = _rsdal.GetFilterData(DTSubCategory, objkgpList.version, objkgpList.lang, StateName, DistrictName); //ds.Tables.Add(DTSubCategory.Copy()); return(ds); }