public IHttpActionResult GetTrendsProducts(string version) { 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(); } DataSet ds = new DataSet(); ds = LiveStocks.BZTrendsProducts(version, x_StateName, x_DistrictName); //ds.Tables[0].TableName = "TrendsProducts";Product,ProductsApiReponse ds.Tables[0].TableName = "Product"; //return Ok(new { TrendsProductsApiReponse = ds, Status = true }); return(Ok(new { ProductsApiReponse = ds, Status = true })); } catch (Exception ex) { LogDal.ErrorLog(this.GetType().Name, MethodBase.GetCurrentMethod().Name, ex.Message, 0); return(Ok(new { ProductsApiReponse = "", Status = false })); } }
public IHttpActionResult LiveStockMethod(int LiveStockID, int BreedId, int MilkAmount, string Mode, string version) { try { DataSet ds = new DataSet(); ds = LiveStocks.GetLiveStock(LiveStockID, BreedId, MilkAmount, Mode, version); ds.Tables[0].TableName = "LiveStockDetails"; ds.Tables[1].TableName = "AnimalDetails"; DataSet ds1 = new DataSet(); ds1 = LiveStocks.BZTrendsProducts("1", "", ""); // ds1 = LiveStocks.BZLiveStockProducts("1"); ds1.Tables[0].TableName = "Products"; ds.Tables.Add(ds1.Tables[0].Copy()); BALLiveStock objLiveStock = new BALLiveStock(); List <BALLiveStock> ListLiveStock = new List <BALLiveStock>(); var liveStockData = ds.Tables[0].AsEnumerable(); var liveStockProduct = ds1.Tables[0].AsEnumerable(); AnimalDetails objAnimal = new AnimalDetails(); objAnimal.LiveStockId = Convert.ToInt32(ds.Tables["AnimalDetails"].Rows[0]["LiveStockId"]); objAnimal.LiveStockName = ds.Tables["AnimalDetails"].Rows[0]["LiveStockName"].ToString(); objAnimal.LiveStockNameHindi = ds.Tables["AnimalDetails"].Rows[0]["LiveStockNameHindi"].ToString(); objAnimal.LiveStockType = Convert.ToInt32(ds.Tables["AnimalDetails"].Rows[0]["LiveStockType"]); objAnimal.BreedId = Convert.ToInt32(ds.Tables["AnimalDetails"].Rows[0]["BreedId"]); objAnimal.BreedName = Convert.ToString(ds.Tables["AnimalDetails"].Rows[0]["BreedName"]); objAnimal.IsMilk = Convert.ToBoolean(ds.Tables["AnimalDetails"].Rows[0]["IsMilk"]); objAnimal.MilkQuantity = Convert.ToInt32(ds.Tables["AnimalDetails"].Rows[0]["MilkQuantity"]); objAnimal.IsActive = Convert.ToBoolean(ds.Tables["AnimalDetails"].Rows[0]["IsActive"]); objAnimal.ImageUrl = ds.Tables["AnimalDetails"].Rows[0]["ImageUrl"].ToString(); objAnimal.BALLiveStock = new List <BALLiveStock>(); foreach (var item in liveStockData) { objAnimal.BALLiveStock.Add(new BALLiveStock { ID = item.Field <int>("ID"), Name = item.Field <string>("Name"), Description = item.Field <string>("Description"), Extra = item.Field <int>("Extra"), IsShow = item.Field <bool>("IsShow"), VideoUrl = item.Field <string>("VideoUrl"), ImageUrl = item.Field <string>("ImageUrl"), Products = new List <Products>() }); } foreach (var ItemList in objAnimal.BALLiveStock) { foreach (var item1 in liveStockProduct) { if (item1.Field <long>("RowNumber") > 1) { ItemList.Products.Add(new Products { RowNumber = item1.Field <long>("RowNumber"), ProductID = item1.Field <int>("ProductID"), ProductName = item1.Field <string>("ProductName"), OrganisationName = item1.Field <string>("OrganisationName"), BrandName = item1.Field <string>("BrandName"), TechnicalName = item1.Field <string>("TechnicalName"), SubCategoryName = item1.Field <string>("SubCategoryName"), CategoryName = item1.Field <string>("CategoryName"), CategoryHindi = item1.Field <string>("CategoryHindi"), CategoryID = item1.Field <byte>("CategoryID"), PackageID = item1.Field <int>("PackageID"), RN = item1.Field <Int64>("RN"), OfferPrice_Qty = item1.Field <int?>("OfferPrice_Qty"), Amount = item1.Field <decimal>("Amount"), UnitName = item1.Field <string>("UnitName"), OurPrice = item1.Field <decimal>("OurPrice"), offerprice = item1.Field <decimal>("offerprice"), RecordID = item1.Field <int>("RecordID"), CreatedDate = item1.Field <DateTime>("CreatedDate"), IsActive = item1.Field <bool>("IsActive"), status = item1.Field <string>("status"), CretedBy = item1.Field <string>("CretedBy"), ProductHindiName = item1.Field <string>("ProductHindiName"), IsDetails = item1.Field <bool>("IsDetails"), ImagePath = item1.Field <string>("ImagePath"), DistrictID = item1.Field <int>("DistrictID"), DistrictName = item1.Field <string>("DistrictName"), COD = item1.Field <decimal>("COD"), OnlinePrice = item1.Field <decimal>("OnlinePrice"), MRP = item1.Field <decimal>("MRP"), OfferDiscount = item1.Field <string>("OfferDiscount") + " छूट" }); } } } return(Ok(new { LiveStockResults = objAnimal, Status = true })); } catch (Exception ex) { LogDal.ErrorLog(this.GetType().Name, MethodBase.GetCurrentMethod().Name, ex.Message, 0); return(Ok(new { LiveStockResults = "", Status = false })); } }