예제 #1
0
        public async Task <IActionResult> Edit(int id, [Bind("VehicleModelId,Name,Description,IsActive,VehicleManufacturerId,CreatedAt,CreatedBy,UpdatedAt,UpdatedBy")] Vehiclemodel vehiclemodel)
        {
            if (id != vehiclemodel.VehicleModelId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(vehiclemodel);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!VehiclemodelExists(vehiclemodel.VehicleModelId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["VehicleManufacturerId"] = new SelectList(_context.Vehiclemanufacturer, "VehicleManufacturerId", "CreatedBy", vehiclemodel.VehicleManufacturerId);
            return(View(vehiclemodel));
        }
예제 #2
0
        public async Task <IActionResult> Create([Bind("VehicleModelId,Name,Description,IsActive,VehicleManufacturerId,CreatedAt,CreatedBy,UpdatedAt,UpdatedBy")] Vehiclemodel vehiclemodel)
        {
            if (ModelState.IsValid)
            {
                _context.Add(vehiclemodel);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["VehicleManufacturerId"] = new SelectList(_context.Vehiclemanufacturer, "VehicleManufacturerId", "CreatedBy", vehiclemodel.VehicleManufacturerId);
            return(View(vehiclemodel));
        }