public async Task <IActionResult> Edit(int id, [Bind("MotorcycleId,Year,Price,Length,Width,Height,Weight,TypeMotorcycleId,BrandId,ModelMotorcycleId,DisplacementId")] Motorcycle motorcycle) { if (id != motorcycle.MotorcycleId) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(motorcycle); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!MotorcycleExists(motorcycle.MotorcycleId)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["BrandId"] = new SelectList(_context.Brand, "BrandId", "Name", motorcycle.BrandId); ViewData["DisplacementId"] = new SelectList(_context.Displacement, "DisplacementId", "Name", motorcycle.DisplacementId); ViewData["ModelMotorcycleId"] = new SelectList(_context.ModelMotorcycle, "ModelMotorcycleId", "Name", motorcycle.ModelMotorcycleId); ViewData["TypeMotorcycleId"] = new SelectList(_context.TypeMotorcycle, "TypeMotorcycleId", "Name", motorcycle.TypeMotorcycleId); return(View(motorcycle)); }
public async Task <IActionResult> Edit(int id, [Bind("TypeMotorcycleId,Name")] TypeMotorcycle typeMotorcycle) { if (id != typeMotorcycle.TypeMotorcycleId) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(typeMotorcycle); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!TypeMotorcycleExists(typeMotorcycle.TypeMotorcycleId)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(typeMotorcycle)); }
public async Task <IActionResult> Edit(int id, [Bind("BrandId,Name")] Brand brand) { if (id != brand.BrandId) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(brand); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!BrandExists(brand.BrandId)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(brand)); }
public async Task <IActionResult> Edit(int id, [Bind("DisplacementId,Name")] Displacement displacement) { if (id != displacement.DisplacementId) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(displacement); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!DisplacementExists(displacement.DisplacementId)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(displacement)); }