public async Task <IActionResult> Edit(int id, [Bind("CarSaleId,CustomerId,SellerId,CarId,Price")] CarSale carSale) { if (id != carSale.CarSaleId) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(carSale); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!CarSaleExists(carSale.CarSaleId)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["CarId"] = new SelectList(_context.Cars, "CarId", "CarYear", carSale.CarId); ViewData["CustomerId"] = new SelectList(_context.Customers, "CustomerId", "CustomerName", carSale.CustomerId); ViewData["SellerId"] = new SelectList(_context.Sellers, "SellerId", "SellerName", carSale.SellerId); return(View(carSale)); }
public async Task <IActionResult> Edit(int id, [Bind("CountryId,CountryName")] Country country) { if (id != country.CountryId) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(country); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!CountryExists(country.CountryId)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(country)); }
public async Task <IActionResult> Edit(int id, [Bind("BrandId,BrandName,CountryId")] 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))); } ViewData["CountryId"] = new SelectList(_context.Countries, "CountryId", "CountryName", brand.CountryId); return(View(brand)); }
public async Task <IActionResult> Edit(int id, [Bind("SellerId,SellerName,CityId")] Seller seller) { if (id != seller.SellerId) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(seller); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!SellerExists(seller.SellerId)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["CityId"] = new SelectList(_context.Cities, "CityId", "CityName", seller.CityId); return(View(seller)); }
public async Task <IActionResult> Edit(int id, [Bind("CarId,BrandId,CarYear,BodyId,Vin,Model,ColorId")] Car car) { if (id != car.CarId) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(car); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!CarExists(car.CarId)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["BodyId"] = new SelectList(_context.Bodies, "BodyId", "BodyName", car.BodyId); ViewData["BrandId"] = new SelectList(_context.Brands, "BrandId", "BrandName", car.BrandId); ViewData["ColorId"] = new SelectList(_context.Colors, "ColorId", "ColorName", car.ColorId); return(View(car)); }