コード例 #1
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,Name,TypeOfCargoId,ShelfLife,Features")] Cargo cargo)
        {
            if (id != cargo.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(cargo);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!CargoExists(cargo.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["TypeOfCargoId"] = new SelectList(_context.TypeOfCargos, "Id", "Name", cargo.TypeOfCargoId);
            return(View(cargo));
        }
コード例 #2
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,FullName,Age,Address,PhoneNumber,PassportData,Position")] Employee employee)
        {
            if (id != employee.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(employee);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!EmployeeExists(employee.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(employee));
        }
コード例 #3
0
ファイル: CarsController.cs プロジェクト: s1mb1os/courseWork
        public async Task <IActionResult> Edit(int id, [Bind("Id,RegNumber,VinNumber,EngineNumber,YearOfIssue,TechInspection,EmployeeId,CarBrandId")] Car car)
        {
            if (id != car.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(car);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!CarExists(car.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["CarBrandId"] = new SelectList(_context.CarBrands, "Id", "Name", car.CarBrandId);
            ViewData["EmployeeId"] = new SelectList(_context.Employees, "Id", "FullName", car.EmployeeId);
            return(View(car));
        }
コード例 #4
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,Name,Description")] TypeOfCargo typeOfCargo)
        {
            if (id != typeOfCargo.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(typeOfCargo);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!TypeOfCargoExists(typeOfCargo.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(typeOfCargo));
        }
コード例 #5
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,Customer,StartPoint,EndPoint,StartDate,EndDate,CarId,CargoId,Price,IsPayment,IsReturn")] Flight flight)
        {
            if (id != flight.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(flight);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!FlightExists(flight.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["CarId"]   = new SelectList(_context.Cars, "Id", "RegNumber", flight.CarId);
            ViewData["CargoId"] = new SelectList(_context.Cargos, "Id", "Name", flight.CargoId);
            return(View(flight));
        }
コード例 #6
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,Name,MaxSpeed,Description,Type")] CarBrand carBrand)
        {
            if (id != carBrand.Id)
            {
                return(NotFound());
            }

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