public async Task <IActionResult> Edit(int id, [Bind("ID,TrainerID,ExersiceID")] ExpTrainer expTrainer) { if (id != expTrainer.ID) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(expTrainer); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ExpTrainerExists(expTrainer.ID)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["ExersiceID"] = new SelectList(_context.Exersice, "ExcerciseID", "ExcerciseID", expTrainer.ExersiceID); ViewData["TrainerID"] = new SelectList(_context.Trainer, "TrainerID", "TrainerID", expTrainer.TrainerID); return(View(expTrainer)); }
public async Task <IActionResult> Create([Bind("ID,TrainerID,ExersiceID")] ExpTrainer expTrainer) { if (ModelState.IsValid) { _context.Add(expTrainer); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["ExersiceID"] = new SelectList(_context.Exersice, "ExcerciseID", "ExcerciseID", expTrainer.ExersiceID); ViewData["TrainerID"] = new SelectList(_context.Trainer, "TrainerID", "TrainerID", expTrainer.TrainerID); return(View(expTrainer)); }