Exemplo n.º 1
0
        public async Task <IActionResult> Edit(int id, [Bind("VehicleID,IsAvailable,Capacity,IsOperable")] Vehicle vehicle)
        {
            if (id != vehicle.VehicleID)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(vehicle);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!VehicleExists(vehicle.VehicleID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(vehicle));
        }
        public async Task <IActionResult> Edit(int id, [Bind("RouteNumber,StartingPoint,EndPoint,StopOne,StopTwo,StopThree")] Route route)
        {
            if (id != route.RouteNumber)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(route);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!RouteExists(route.RouteNumber))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(route));
        }
        public async Task <IActionResult> Edit(int id, [Bind("DriverID,DriverName,DriverContactNumber,Location,VehicleNumber,Capacity,SeatsAvailable")] Vehicle vehicle)
        {
            // if (id != vehicle.DriverID)
            // {
            //   return NotFound();
            //}

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