public IActionResult DealAllProducts() { var finalDeal = DealHelper.getdeals(db); var DealList = new List <Deal>(); var dealLists = new DealLists(); var DealListsss = new List <DealLists>(); try { foreach (var item in finalDeal) { var productList = new List <product7>(); dealLists = new DealLists(); dealLists.Id = item.Id; dealLists.ListName = item.Name; dealLists.ActiveFrom = item.ActiveFrom.Date.ToShortDateString() + "" + item.ActiveFromTime; dealLists.ActiveTo = item.ActiveFrom.Date.ToShortDateString() + "" + item.ActiveFromTime; //foreach (var item2 in item.DealProduct) //{ // var ProductData = allProducts(item2.ProductId, item.Name, 1); // productList.Add(ProductData); //} //dealLists.products.AddRange(productList); dealLists.products = allProducts(item.DealProduct.Select(x => x.ProductVariantId).ToList(), item.Id); DealListsss.Add(dealLists); } return(Ok(DealListsss)); } catch (Exception ex) { throw ex; } }
public IActionResult getDealsProductsMobile() { var finalDeal = DealHelper.getdeals(db); finalDeal = finalDeal.Where(x => x.IsShow == true).ToList();//to show on home page var DealList = new List <Deal>(); var dealLists = new DealLists(); var DealListsss = new List <DealLists>(); try { foreach (var item in finalDeal) { var productList = new List <product7>(); dealLists = new DealLists(); dealLists.Id = item.Id; dealLists.ListName = item.Name; dealLists.ActiveFrom = item.ActiveFrom.Date.ToShortDateString() + " " + item.ActiveFromTime; dealLists.ActiveTo = item.ActiveTo.Date.ToShortDateString() + " " + item.ActiveToTime; var list = allProducts(item.DealProduct.Select(x => x.ProductVariantId).ToList(), item.Id); dealLists.products = list.Take(4).OrderByDescending(x => x.Id).ToList(); DealListsss.Add(dealLists); } return(Ok(DealListsss)); } catch (Exception ex) { throw ex; } }