예제 #1
0
        public async Task <IActionResult> Edit(int id, [Bind("ID_Color_Product,Color_Name,ID_Product,Image")] Color_Product color_Product)
        {
            if (id != color_Product.ID_Color_Product)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(color_Product);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!Color_ProductExists(color_Product.ID_Color_Product))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["ID_Product"] = new SelectList(_context.Product, "ID_Product", "Product_Name", color_Product.ID_Product);
            return(View(color_Product));
        }
예제 #2
0
        public async Task <IActionResult> Create([Bind("ID_Color_Product,Color_Name,ID_Product,Image")] Color_Product color_Product)
        {
            if (ModelState.IsValid)
            {
                _context.Add(color_Product);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["ID_Product"] = new SelectList(_context.Product, "ID_Product", "Product_Name", color_Product.ID_Product);
            return(View(color_Product));
        }