public async Task <IActionResult> Edit(int id, [Bind("ID,PlantID,PlantTypeID")] PlantPlantType plantPlantType) { if (id != plantPlantType.ID) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(plantPlantType); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!PlantPlantTypeExists(plantPlantType.ID)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["PlantID"] = new SelectList(_context.Plant, "ID", "Name", plantPlantType.PlantID); ViewData["PlantTypeID"] = new SelectList(_context.PlantType, "ID", "Name", plantPlantType.PlantTypeID); return(View(plantPlantType)); }
public async Task <IActionResult> Create([Bind("ID,PlantID,PlantTypeID")] PlantPlantType plantPlantType) { if (ModelState.IsValid) { _context.Add(plantPlantType); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["PlantID"] = new SelectList(_context.Plant, "ID", "Name", plantPlantType.PlantID); ViewData["PlantTypeID"] = new SelectList(_context.PlantType, "ID", "Name", plantPlantType.PlantTypeID); return(View(plantPlantType)); }