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)); }
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)); }