Exemplo n.º 1
0
        public async Task <IActionResult> addTocartAsync(int id)
        {
            Member myUser = await userManager.GetUserAsync(User);

            if (User.Identity.IsAuthenticated)
            {
                ViewBag.CartCount = unitOfWork.TemporaryItemsRepository.GetAll(new string[] { }).Where(x => x.MemberId == myUser.Id).Count();
                ViewBag.FavCount  = unitOfWork.MemberProductFavouriteRepository.GetAll(new string[] { }).Where(x => x.MemberId == myUser.Id).Count();
            }

            var chkAdd = unitOfWork.TemporaryItemsRepository.Find(w => w.ProductId == id && w.MemberId == myUser.Id, new string[] { });

            if (chkAdd.Count() == 0)
            {
                TemporaryItems temp = new TemporaryItems()
                {
                    ProductId = id,
                    MemberId  = myUser.Id
                };
                unitOfWork.TemporaryItemsRepository.Add(temp);
                unitOfWork.Complete();
            }

            return(RedirectToAction("Details", "product", new { id = id }));
        }
        public async Task <IActionResult> addTocartAsync(int id)
        {
            Member myUser = await userManager.GetUserAsync(User);

            var chkAdd = unitOfWork.TemporaryItemsRepository.Find(w => w.ProductId == id && w.MemberId == myUser.Id, new string[] { });

            if (chkAdd.Count() == 0)
            {
                TemporaryItems temp = new TemporaryItems()
                {
                    ProductId = id,
                    MemberId  = myUser.Id
                };
                unitOfWork.TemporaryItemsRepository.Add(temp);
                unitOfWork.Complete();
            }

            return(RedirectToAction("Details", "product", new { id = id }));
        }
Exemplo n.º 3
0
        //l1
        public void FillUpBinI(string itemAllocationMethod, IUtilities Utilities)
        {
            NotRemovedItems = new List <Item>();
            //cerco la posizione migliore per ogni item j'
            foreach (Item temporaryItem in TemporaryItems)
            {
                if (!temporaryItem.IsRemoved)
                {
                    Utilities.IsBestPositionFound(TemporaryBins.ElementAt(i), temporaryItem, itemAllocationMethod);
                    //salvo un bin nuovo ogni volta che  viene aggiunto un elemento

                    /*var tempBin = temporaryBins[i];
                     * Bin<Tuple> b;
                     *
                     * if (tempBin.NestedItems != null)
                     * {
                     *  b = new Bin<Tuple>
                     *  {
                     *      Id = tempBin.Id,
                     *      Height = tempBin.Height,
                     *      Width = tempBin.Width,
                     *      Points = new List<Tuple>(tempBin.Points),
                     *      NestedItems = new List<Item>(tempBin.NestedItems)
                     *  };
                     *  sequence.Bins.Add(b);
                     * }
                     * else
                     * {
                     *  b = new Bin<Tuple>
                     *  {
                     *      Id = tempBin.Id,
                     *      Height = tempBin.Height,
                     *      Width = tempBin.Width,
                     *      Points = new List<Tuple>(tempBin.Points),
                     *      NestedItems = new List<Item>()
                     *  }
                     * }*/
                }
            }

            NotRemovedItems = TemporaryItems.Where(x => x.IsRemoved == false).ToList();
        }