public async Task <IActionResult> Edit(int id, [Bind("Id,Name,Description,Price,SalePrice,ImageLOC,InStore")] Item item)
        {
            if (id != item.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(item);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!ItemExists(item.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(item));
        }
Beispiel #2
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,EntryItemId,UserId,Quantity")] CartEntry cartEntry)
        {
            if (id != cartEntry.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(cartEntry);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!CartEntryExists(cartEntry.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(cartEntry));
        }
Beispiel #3
0
        public async Task <IActionResult> Edit(string id, [Bind("Id")] Cart cart)
        {
            if (id != cart.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(cart);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!CartExists(cart.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(cart));
        }
Beispiel #4
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,Name,Code,PercentOff,StartDate,EndDate")] Promotion promotion)
        {
            if (id != promotion.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(promotion);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!PromotionExists(promotion.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(promotion));
        }
        public IActionResult UpdateAccount(int userid, string password, string billingAddress)
        {
            User user = _context.Users.SingleOrDefault(u => u.Id == userid);

            if (password != null)
            {
                byte[] data = System.Text.Encoding.ASCII.GetBytes(password);
                data          = new System.Security.Cryptography.SHA256Managed().ComputeHash(data);
                user.Password = System.Text.Encoding.ASCII.GetString(data);
            }
            if (password != null)
            {
                user.BillingAddress = billingAddress;
            }
            _context.Update(user);
            _context.SaveChangesAsync();

            return(View("EditSuccess"));
        }
Beispiel #6
0
        private void HandleExistingCart(CartItem item, CustomerCart cart)
        {
            var existingProcut = cart.ExistingItemCart(item);

            cart.AddItem(item);
            ValidateCart(cart);
            if (existingProcut)
            {
                _context.Update(cart.GetProductById(item.ProductId));
            }
            else
            {
                _context.Add(item);
            }

            _context.CustomersCart.Update(cart);
        }