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"));
        }
Exemple #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));
        }
        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));
        }
Exemple #4
0
        public CreateNewListingViewModel CreateNewListing(dm.ProductInfo specificProduct)
        {
            var productInfo = FindProductInfoHelper.SingleProductInfo(specificProduct);

            return(createModel.MappingCreateListing(productInfo));
        }
Exemple #5
0
        public CreateNewListingViewModel MappingCreateListing(dm.ProductInfo item)
        {
            var listingMapper = listingConfig.CreateMapper();

            return(listingMapper.Map <dm.ProductInfo, CreateNewListingViewModel>(item));
        }