public async Task <IActionResult> Edit(int id, [Bind("FleetSizeId,FleetCategoryId,StationId,DepartmentId")] FleetSize fleetSize) { if (id != fleetSize.FleetSizeId) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(fleetSize); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!FleetSizeExists(fleetSize.FleetSizeId)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["DepartmentId"] = new SelectList(_context.Department, "DepartmentId", "Comment", fleetSize.DepartmentId); ViewData["FleetCategoryId"] = new SelectList(_context.FleetCategory, "FleetCategoryId", "Mileage", fleetSize.FleetCategoryId); ViewData["StationId"] = new SelectList(_context.Set <Station>(), "StationId", "Location", fleetSize.StationId); return(View(fleetSize)); }
public async Task <IActionResult> Create([Bind("FleetSizeId,FleetCategoryId,StationId,DepartmentId")] FleetSize fleetSize) { if (ModelState.IsValid) { _context.Add(fleetSize); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["DepartmentId"] = new SelectList(_context.Department, "DepartmentId", "Comment", fleetSize.DepartmentId); ViewData["FleetCategoryId"] = new SelectList(_context.FleetCategory, "FleetCategoryId", "Mileage", fleetSize.FleetCategoryId); ViewData["StationId"] = new SelectList(_context.Set <Station>(), "StationId", "Location", fleetSize.StationId); return(View(fleetSize)); }