コード例 #1
0
        public async Task <IActionResult> Edit(int id, [Bind("ID,DateFilled,DateEmpty,GallonsFilled,MilesDriven")] Fillup fillup)
        {
            if (id != fillup.ID)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(fillup);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!FillupExists(fillup.ID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(fillup));
        }
コード例 #2
0
        public async Task <IActionResult> Edit(int id, [Bind("ID,Make,Year,Model")] Vehicle vehicle)
        {
            if (id != vehicle.ID)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(vehicle);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!VehicleExists(vehicle.ID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(vehicle));
        }
コード例 #3
0
        public async Task <IActionResult> Edit(int id, [Bind("ID,Name")] Owner owner)
        {
            if (id != owner.ID)
            {
                return(NotFound());
            }

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