public async Task<IActionResult> Edit(int id, [Bind("Id,CityId,Name")] qvObject qvObject) { if (id != qvObject.Id) { return NotFound(); } if (ModelState.IsValid) { try { _context.Update(qvObject); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!qvObjectExists(qvObject.Id)) { return NotFound(); } else { throw; } } return RedirectToAction("Index"); } ViewData["CityId"] = new SelectList(_context.Cities, "Id", "City", qvObject.CityId); return View(qvObject); }
public async Task <IActionResult> ObjectsEdit(int id, [Bind("Id,CityId,Name")] qvObject qvObject) { /*if (id != qvObject.Id) * { * return NotFound(); * } * * if (ModelState.IsValid) * { * try * { * _context.Update(qvObject); * await _context.SaveChangesAsync(); * } * catch (DbUpdateConcurrencyException) * { * if (!qvObjectExists(qvObject.Id)) * { * return NotFound(); * } * else * { * throw; * } * } * return RedirectToAction("Index"); * } * ViewData["CityId"] = new SelectList(_context.Cities, "Id", "City", qvObject.CityId); * return View(qvObject);*/ return(View()); }
public async Task<IActionResult> Create([Bind("Id,CityId,Name")] qvObject qvObject) { if (ModelState.IsValid) { _context.Add(qvObject); await _context.SaveChangesAsync(); return RedirectToAction("Index"); } ViewData["CityId"] = new SelectList(_context.Cities, "Id", "City", qvObject.CityId); return View(qvObject); }