Ejemplo n.º 1
0
        public IActionResult CreateListing(CreateNewListingViewModel passedInfo)
        {
            var model = new CreateNewListingViewModel();
            var id    = HttpContext.Session.GetInt32("SellingProductId");

            dm.ProductInfo productInfo = FindProductInfoHelper.SingleProductById((int)id);

            var listing = new dm.Listing
            {
                UserSetPrice = passedInfo.UserSetPrice,
                Quantity     = passedInfo.Quantity,
                Size         = passedInfo.Size,
                User         = new dm.User
                {
                    UserId = (int)HttpContext.Session.GetInt32("UserId")
                },
                ProductInfo = new dm.ProductInfo
                {
                    ProductInfoId = (int)HttpContext.Session.GetInt32("SellingProductId")
                }
            };

            model.AddListing(listing);

            return(RedirectToAction("Account", "Home"));
        }
Ejemplo n.º 2
0
        public IActionResult Listing(string sellItem)
        {
            var productId = Int32.Parse(sellItem);

            HttpContext.Session.SetInt32("SellingProductId", productId);
            dm.ProductInfo            domainModel = FindProductInfoHelper.SingleProductById(productId);
            var                       viewModel   = new ConversionNewListing();
            CreateNewListingViewModel listing     = viewModel.MappingCreateListing(domainModel);

            return(View("~/Views/Store/Listing.cshtml", listing));
        }
Ejemplo n.º 3
0
        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));
        }
Ejemplo n.º 4
0
        public void Test_SingleProductById()
        {
            var sut = FindProductInfoHelper.SingleProductById(productInfo.ProductInfoId);

            Assert.Equal(sut.ProductInfoId, productInfo.ProductInfoId);
        }