public async Task <IActionResult> Edit(long id, [Bind("Id,CategoryName")] 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));
        }
示例#2
0
        public async Task <IActionResult> Edit(long id, [Bind("Code,Name,Price,Description,CategoryId")] Product product)
        {
            if (id != product.Code)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(product);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!ProductExists(product.Code))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["CategoryId"] = new SelectList(_context.Category, "Id", "CategoryName", product.CategoryId);
            return(View(product));
        }
示例#3
0
        public async Task <IActionResult> Edit(long id, [Bind("Id,Amount,Orderdate,ConfirmationNumber,CustomerId")] CustomerOrder customerOrder)
        {
            if (id != customerOrder.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(customerOrder);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!CustomerOrderExists(customerOrder.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["CustomerId"] = new SelectList(_context.Customer, "Id", "Addressline1", customerOrder.CustomerId);
            return(View(customerOrder));
        }
示例#4
0
        public async Task <IActionResult> Edit(long id, [Bind("Id,Firstname,Lastname,Addressline1,Addressline2,City,Postcode,Country,Company,Creditcardexpiry,Creditcardnumber,Creditcardtype,Emailaddress,Loginpassword")] Customer customer)
        {
            if (id != customer.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(customer);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!CustomerExists(customer.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(customer));
        }
        public async Task<IActionResult> Edit(long id, [Bind("CustomerOrderId,ProductCode,Quantity")] OrderedProduct orderedProduct)
        {
            if (id != orderedProduct.CustomerOrderId)
            {
                return NotFound();
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(orderedProduct);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!OrderedProductExists(orderedProduct.CustomerOrderId))
                    {
                        return NotFound();
                    }
                    else
                    {
                        throw;
                    }
                }
                return RedirectToAction(nameof(Index));
            }
            ViewData["CustomerOrderId"] = new SelectList(_context.CustomerOrder, "Id", "Id", orderedProduct.CustomerOrderId);
            ViewData["ProductCode"] = new SelectList(_context.Product, "Code", "Name", orderedProduct.ProductCode);
            return View(orderedProduct);
        }