예제 #1
0
        public async Task AddItemToCart(int itemId)
        {
            Item item = await _itemRepo.GetById(itemId);

            if (item == null)
            {
                throw new NullReferenceException();
            }

            CartItemDTO cartItem = _mapper.Map <Item, CartItemDTO> (item);

            if (!_s.IsAvailable)
            {
                await _s.LoadAsync().ConfigureAwait(false);
            }

            var cartItems = GetCartItems();

            if (!Exist(cartItem, cartItems))
            {
                cartItems.Add(cartItem);
                _s.SetString(_key, JsonConvert.SerializeObject(cartItems));
                await _s.CommitAsync().ConfigureAwait(false);
            }
        }
예제 #2
0
        public ActionResult Edit(int id)
        {
            Item item = _itemRepo.GetById(id);

            if (null != item)
            {
                item.ItemName += " (u)";
                item.Quantity += 1;
                _itemRepo.Update(item);
            }

            return(RedirectToAction("Index"));
        }