public IActionResult ProductInfoView(string viewItem) { int selectedProductId; if (viewItem == null) { selectedProductId = Int32.Parse(HttpContext.Session.GetString("ProductId")); } else { HttpContext.Session.SetString("ProductId", viewItem); selectedProductId = Int32.Parse(viewItem); } var convert = new ConversionListing(); List <dm.Listing> allListings = ListingHelper.GetAllListingsByProductInfoId(selectedProductId); dm.ProductInfo productInfo = FindProductInfoHelper.SingleProductById(selectedProductId); List <SingleProductViewModel> convertedList = convert.MappingAllViewListings(allListings); foreach (var item in convertedList) { item.Color = productInfo.Color; item.Description = productInfo.Description; item.ImageUrl = productInfo.ImageUrl; item.DisplayPrice = productInfo.DisplayPrice; item.ReleaseDate = productInfo.ReleaseDate; item.ProductTitle = productInfo.ProductTitle; } if (convertedList.Count == 0) { convertedList.Add(new SingleProductViewModel { Color = productInfo.Color, Description = productInfo.Description, ImageUrl = productInfo.ImageUrl, DisplayPrice = productInfo.DisplayPrice, ReleaseDate = productInfo.ReleaseDate, ProductTitle = productInfo.ProductTitle }); } return(View("~/Views/Store/SingleItem.cshtml", convertedList)); }
public void Test_GetAllListingByProductInfoId() { var sut = ListingHelper.GetAllListingsByProductInfoId(listing2.ProductInfo.ProductInfoId); Assert.NotEmpty(sut); }