public async Task <IActionResult> Edit(string id, [Bind("number,child,pets,model,id_venichle_type")] AddVenichle addVenichle) { if (id != addVenichle.number) { return(NotFound()); } if (ModelState.IsValid) { try { Venichles ven = _context.Venichles.First(u => u.number == id); ven.id_driver = User.Identity.Name; ven.number = addVenichle.number; ven.child = addVenichle.child; ven.pets = addVenichle.pets; ven.model = addVenichle.model; ven.venicle_type = addVenichle.id_venichle_type; _context.Update(ven); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { ModelState.AddModelError("", "Error"); } return(RedirectToAction("Index")); } return(View("Edit", addVenichle)); }
public async Task <IActionResult> Add([Bind("number,child,pets,model,id_venichle_type")] AddVenichle addVenichle) { if (ModelState.IsValid) { _context.Venichles.Add(new Venichles() { id_driver = User.Identity.Name, number = addVenichle.number, child = addVenichle.child, pets = addVenichle.pets, model = addVenichle.model, venicle_type = addVenichle.id_venichle_type }); await _context.SaveChangesAsync(); return(RedirectToAction("Index")); } return(View("AddVenichle")); }
public IActionResult Edit(string id) { if (id == null) { return(NotFound()); } Venichles ven = _context.Venichles.First(u => u.number == id); var addVenichle = new AddVenichle() { number = ven.number, model = ven.model, id_venichle_type = ven.venicle_type, child = ven.child, pets = ven.pets }; ViewData["id_venichle_type"] = new SelectList(_context.Order_types, "id", "name"); return(View("Edit", addVenichle)); }