コード例 #1
0
        public async Task <IActionResult> Edit(int id, [Bind("AutoCarId,NameAuto,Number,Mileage,TypeFuelId,NormaFuelId,TrailerId,DriverId,TypeAutoId,TireId,Harmfulness,Navigation,Injector")] AutoCar autoCar)
        {
            if (id != autoCar.AutoCarId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(autoCar);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!AutoCarExists(autoCar.AutoCarId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["DriverId"]    = new SelectList(_context.Drivers, "DriverId", "FirsLastMidName", autoCar.DriverId);
            ViewData["NormaFuelId"] = new SelectList(_context.NormaFuels, "NormaFuelId", "Linear", autoCar.NormaFuelId);
            ViewData["TireId"]      = new SelectList(_context.Tires, "TireId", "Name", autoCar.TireId);
            ViewData["TrailerId"]   = new SelectList(_context.Trailers, "TrailerId", "Number", autoCar.TrailerId);
            ViewData["TypeAutoId"]  = new SelectList(_context.TypeAutos, "TypeAutoId", "NameType", autoCar.TypeAutoId);
            ViewData["TypeFuelId"]  = new SelectList(_context.TypeFuels, "TypeFuelId", "Fuel", autoCar.TypeFuelId);
            return(View(autoCar));
        }
コード例 #2
0
        public static void Decorator()
        {
            TaxiCar      taxi         = new TaxiCar();
            CarDecorator carDecorator = new AutoCar(taxi);

            carDecorator.Go();
        }
コード例 #3
0
        public async Task <IActionResult> Create([Bind("AutoCarId,NameAuto,Number,Mileage,TypeFuelId,NormaFuelId,TrailerId,DriverId,TypeAutoId,TireId,Harmfulness,Navigation,Injector")] AutoCar autoCar)
        {
            if (ModelState.IsValid)
            {
                _context.Add(autoCar);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["DriverId"]    = new SelectList(_context.Drivers, "DriverId", "FirsLastMidName", autoCar.DriverId);
            ViewData["NormaFuelId"] = new SelectList(_context.NormaFuels, "NormaFuelId", "Linear", autoCar.NormaFuelId);
            ViewData["TireId"]      = new SelectList(_context.Tires, "TireId", "Name", autoCar.TireId);
            ViewData["TrailerId"]   = new SelectList(_context.Trailers, "TrailerId", "Number", autoCar.TrailerId);
            ViewData["TypeAutoId"]  = new SelectList(_context.TypeAutos, "TypeAutoId", "NameType", autoCar.TypeAutoId);
            ViewData["TypeFuelId"]  = new SelectList(_context.TypeFuels, "TypeFuelId", "Fuel", autoCar.TypeFuelId);
            return(View(autoCar));
        }