public async Task <IActionResult> Edit(int id, [Bind("VehicleAnnotationId,Content,Date,VehicleId")] VehicleAnnotations vehicleAnnotations) { if (id != vehicleAnnotations.VehicleAnnotationId) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(vehicleAnnotations); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!VehicleAnnotationsExists(vehicleAnnotations.VehicleAnnotationId)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["VehicleId"] = new SelectList(_context.Vehicle, "VehicleId", "RegistrationNumber", vehicleAnnotations.VehicleId); return(View(vehicleAnnotations)); }
public async Task <IActionResult> Create([Bind("VehicleAnnotationId,Content,Date,VehicleId")] VehicleAnnotations vehicleAnnotations) { if (ModelState.IsValid) { _context.Add(vehicleAnnotations); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["VehicleId"] = new SelectList(_context.Vehicle, "VehicleId", "RegistrationNumber", vehicleAnnotations.VehicleId); return(View(vehicleAnnotations)); }