示例#1
0
        public async Task <IActionResult> Edit(int id, [Bind("ID,CompanyName,Phone")] Supplier supplier)
        {
            if (id != supplier.ID)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(supplier);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!SupplierExists(supplier.ID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(supplier));
        }
示例#2
0
        public async Task <IActionResult> Edit(int id, [Bind("ProductID,ProductName,SupplierID,UnitPrice,AmountInLBS,ArrivalTime,ExpirationDate")] Product product)
        {
            if (id != product.ProductID)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(product);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!ProductExists(product.ProductID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["SupplierID"] = new SelectList(_context.Suppliers, "ID", "ID", product.SupplierID);
            return(View(product));
        }
        public async Task <IActionResult> Edit(int id, [Bind("ID,DateOfReservation,Cancelled,PartyName")] Reservation reservation)
        {
            if (id != reservation.ID)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    // Reservations cannot be created already cancelled
                    reservation.Cancelled = false;

                    _context.Update(reservation);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!ReservationExists(reservation.ID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(reservation));
        }
示例#4
0
        public async Task <IActionResult> Edit(int id, [Bind("MealID,MealName,MealPrice,Description,Active")] Meal meal)
        {
            if (id != meal.MealID)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(meal);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!MealExists(meal.MealID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(meal));
        }