public async Task <IActionResult> Edit(int id, [Bind("CourseHandicapId,CourseId,MenHcp01,MenHcp02,MenHcp03,MenHcp04,MenHcp05,MenHcp06,MenHcp07,MenHcp08,MenHcp09,MenHcp10,MenHcp11,MenHcp12,MenHcp13,MenHcp14,MenHcp15,MenHcp16,MenHcp17,MenHcp18,LadiesHcp01,LadiesHcp02,LadiesHcp03,LadiesHcp04,LadiesHcp05,LadiesHcp06,LadiesHcp07,LadiesHcp08,LadiesHcp09,LadiesHcp10,LadiesHcp11,LadiesHcp12,LadiesHcp13,LadiesHcp14,LadiesHcp15,LadiesHcp16,LadiesHcp17,LadiesHcp18")] CourseHandicap courseHandicap) { if (id != courseHandicap.CourseId) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(courseHandicap); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!CourseHandicapExists(courseHandicap.CourseHandicapId)) { return(NotFound()); } else { throw; } } return(RedirectToAction("Index", "Course")); } var model = new CourseHandicapEditViewModel(courseHandicap); model.Course = await _context.Course.SingleOrDefaultAsync(r => r.CourseId == id); return(View(model)); }
// GET: CourseHandicap/Edit/5 public async Task <IActionResult> Edit(int?id) { if (id == null) { return(NotFound()); } var courseHandicap = await _context.CourseHandicap.SingleOrDefaultAsync(m => m.CourseId == id); if (courseHandicap == null) { courseHandicap = new CourseHandicap(); courseHandicap.CourseId = (int)id; _context.Add(courseHandicap); await _context.SaveChangesAsync(); } var model = new CourseHandicapEditViewModel(courseHandicap); model.Course = await _context.Course.SingleOrDefaultAsync(r => r.CourseId == id); return(View(model)); }