Пример #1
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"));
        }
Пример #2
0
        public IActionResult BuyerSearch(List <FindProductInfoViewModel> findProductInfos, string sell)
        {
            c.SneakerDropDbContext db = new c.SneakerDropDbContext();
            if (sell != null)
            {
                HttpContext.Session.SetString("Selling", sell);
            }

            foreach (var item in findProductInfos)
            {
                string PTitle = item.ProductTitle;
                HttpContext.Session.SetString("ProductName", PTitle.Trim());
            }

            if (sell == "seller")
            {
                return(RedirectToAction("SellCatalog", "Home"));
            }
            return(RedirectToAction("Catalog", "Home"));
        }
Пример #3
0
        public IActionResult Catalog()
        {
            cd.SneakerDropDbContext db = new cd.SneakerDropDbContext();
            var sessionproduct         = HttpContext.Session.GetString("ProductName");
            var model = new FindProductInfoViewModel {
                ProductTitle = sessionproduct
            };
            List <FindProductInfoViewModel> results = model.FindMatchingProductInfo(model);
            var createcatalog2 = db.Type.Where(t => t.TypeName.Contains(sessionproduct)).ToList();
            List <FindProductInfoViewModel> onlyType = new List <FindProductInfoViewModel>();


            if (results == null)
            {
                foreach (var item1 in createcatalog2)
                {
                    var typeid         = item1.TypeId;
                    var createcatalog3 = db.ProductInfos.Where(p => p.Type.TypeId == typeid).ToList();
                    var typeList       = model.ConvertListOnly(createcatalog3);
                    onlyType.AddRange(typeList);
                }

                return(View("~/Views/Store/Catalog.cshtml", onlyType));
            }
            foreach (var item2 in createcatalog2)
            {
                var typeid         = item2.TypeId;
                var createcatalog3 = db.ProductInfos.Where(p => p.Type.TypeId == typeid).ToList();
                var typeList       = model.ConvertListOnly(createcatalog3);
                results.AddRange(typeList);
            }

            // for if user inputs something that doesnt exist in db
            if (results.Count == 0 && createcatalog2.Count == 0)
            {
                return(View("~/Views/Store/SellerCatalog.cshtml", onlyType));
            }

            return(View("~/Views/Store/Catalog.cshtml", results));
        }