public IActionResult Edit(int id, [Bind("Id,ProductName,Price,ProductCategoryId")] Product product)
        {
            if (id != product.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(product);
                    _context.SaveChanges();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!ProductExists(product.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["ProductCategoryId"] = new SelectList(_context.Set <ProductCategory>(), "Id", "Id", product.ProductCategoryId);
            return(View(product));
        }
Пример #2
0
        public IActionResult Edit(int id, [Bind("Id,Name,ContactNumber")] Retailer retailer)
        {
            if (id != retailer.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(retailer);
                    _context.SaveChanges();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!RetailerExists(retailer.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(retailer));
        }
        public IActionResult Edit(int id, [Bind("Id,ProductId,RetailerId,DeliveryStatus")] ProductRetailerRegistration productRetailerRegistration)
        {
            if (id != productRetailerRegistration.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(productRetailerRegistration);
                    _context.SaveChanges();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!ProductRetailerRegistrationExists(productRetailerRegistration.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["ProductId"]  = new SelectList(_context.Product, "Id", "Id", productRetailerRegistration.ProductId);
            ViewData["RetailerId"] = new SelectList(_context.Set <Retailer>(), "Id", "Id", productRetailerRegistration.RetailerId);
            return(View(productRetailerRegistration));
        }
Пример #4
0
        public IActionResult Edit(int id, [Bind("Id,Name,Description")] ProductCategory productCategory)
        {
            if (id != productCategory.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(productCategory);
                    _context.SaveChanges();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!ProductCategoryExists(productCategory.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(productCategory));
        }