Exemplo n.º 1
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,Name,Description,Price,Category_id")] Product product)
        {
            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)));
            }
            ViewData["Category_id"] = new SelectList(_context.Categories, "id", "Name", product.Category_id);
            return(View(product));
        }
Exemplo n.º 2
0
        public async Task <IActionResult> Edit(int id, [Bind("id,Shoppinglist_id,Product_id,Amount")] Shoppinglist_Product shoppinglist_Product)
        {
            if (id != shoppinglist_Product.id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(shoppinglist_Product);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!Shoppinglist_ProductExists(shoppinglist_Product.id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["Product_id"]      = new SelectList(_context.Products, "Id", "Description", shoppinglist_Product.Product_id);
            ViewData["Shoppinglist_id"] = new SelectList(_context.ShoppingLists, "id", "Customer_id", shoppinglist_Product.Shoppinglist_id);
            return(View(shoppinglist_Product));
        }
Exemplo n.º 3
0
        public async Task <IActionResult> Edit(int id, [Bind("id,Name,LocationId")] Category category)
        {
            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)));
            }
            return(View(category));
        }