Exemplo 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"));
        }
Exemplo n.º 2
0
        public IActionResult CartInfo()
        {
            //second in route of cart
            c.SneakerDropDbContext _db = new c.SneakerDropDbContext();

            //retrieves the Json object and deserializes into a list of ListingIds
            var getIdList = JsonConvert.DeserializeObject <List <int> >(HttpContext.Session.GetString("ListOfIds"));
            var getnodup  = HttpContext.Session.GetInt32("nodup");

            dm.Listing results             = _db.Listings.Where(l => l.ListingId == getIdList[0]).Include(l => l.ProductInfo).FirstOrDefault();
            OrderAndPaymentViewModel model = new OrderAndPaymentViewModel
            {
                ListingId     = getIdList[0],
                Quantity      = results.Quantity,
                ProductInfoId = results.ProductInfoId,
                UserSetPrice  = (decimal)results.UserSetPrice,
                Size          = results.Size,
                ProductTitle  = results.ProductInfo.ProductTitle,
                Color         = results.ProductInfo.Color,
                ImageUrl      = results.ProductInfo.ImageUrl
            };


            ListOfProducts.Add(model);

            if (HttpContext.Session.GetInt32("deletehelper") == 1)
            {
                var deleteid = HttpContext.Session.GetInt32("listingiddelete");
                ListOfProducts.RemoveAll(p => p.ListingId == deleteid);
                HttpContext.Session.SetString("ProductTime", JsonConvert.SerializeObject(ListOfProducts));
            }
            HttpContext.Session.SetString("ProductTime", JsonConvert.SerializeObject(ListOfProducts));

            return(RedirectToAction("Cart", "Home"));
        }
Exemplo n.º 3
0
        // here is pending
        public bool AddListing(dm.Listing listing)
        {
            var checkShoeSize = validator.ValidateShoeSize(listing);

            if (checkShoeSize)
            {
                ListingHelper.AddListingById(listing);
                return(true);
            }
            return(false);
        }
Exemplo n.º 4
0
        public CreateNewListingViewModel MappingListing(dm.Listing listing)
        {
            var listingMapper = listingConfig.CreateMapper();

            return(listingMapper.Map <dm.Listing, CreateNewListingViewModel>(listing));
        }