public async Task <IActionResult> Edit(int id, [Bind("ID,ProgramID,Title")] ProgramWeek programWeek) { if (id != programWeek.ID) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(programWeek); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ProgramWeekExists(programWeek.ID)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(programWeek)); }
public async Task <IActionResult> Create([Bind("ID,ProgramID,Title")] ProgramWeek programWeek) { if (ModelState.IsValid) { _context.Add(programWeek); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(programWeek)); }
private void CreateProgramWeeksForProgram(int numberOfWeeks, int programID, int startingNumberOfWeeks = 1) { int i = startingNumberOfWeeks; for (i = startingNumberOfWeeks; i <= numberOfWeeks; i++) { ProgramWeek week = new ProgramWeek(); week.ProgramID = programID; week.Title = "Week " + i; week.WeekSequenceNum = i; _context.Add(week); } }