public async Task <IActionResult> Edit(int id, [Bind("Id,Image,Description,price")] Product product)
        {
            if (HttpContext.Session.GetString("FirstName") != "L&G1234")
            {
                return(RedirectToAction("Login", "Clients"));
            }
            if (id != product.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(product);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!ProductExists(product.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(product));
        }
        public async Task <IActionResult> Edit(int id, [Bind("Id,Name,SubCategoryId")] Category category)
        {
            if (HttpContext.Session.GetString("FirstName") != "L&G1234")
            {
                return(RedirectToAction("Login", "Clients"));
            }
            if (id != category.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(category);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!CategoryExists(category.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["SubCategoryId"] = new SelectList(_context.Set <SubCategory>(), "Id", "Name", category.SubCategoryId);
            return(View(category));
        }
예제 #3
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,FirstName,LastName,Password,PhoneNumber,Email,DateOfBirth")] Client client)
        {
            if (id != client.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(client);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!ClientExists(client.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(client));
        }
예제 #4
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,Street,City,HouseNumber,Zip")] Address address)
        {
            if (id != address.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(address);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!AddressExists(address.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(address));
        }
        public async Task <IActionResult> Edit(int 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));
        }
예제 #6
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,Name")] SubCategory subCategory)
        {
            if (HttpContext.Session.GetString("FirstName") != "L&G1234")
            {
                return(RedirectToAction("Login", "Clients"));
            }
            if (id != subCategory.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(subCategory);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!SubCategoryExists(subCategory.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(subCategory));
        }
        public async Task <IActionResult> Edit(int id, [Bind("Id,Sum,CartId")] Order order)
        {
            if (HttpContext.Session.GetString("FirstName") != "L&G1234")
            {
                return(RedirectToAction("Login", "Clients"));
            }
            if (id != order.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(order);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!OrderExists(order.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["CartId"] = new SelectList(_context.Cart, "Id", "Id", order.CartId);
            return(View(order));
        }