public async Task OnGetAsync(int?id, int?speakerID) { SacProgram = new SacProgramIndexData(); SacProgram.SacPrograms = await _context.SacProgram .Include(i => i.Speakers) //.ThenInclude(i => i.Speaker) .AsNoTracking() .OrderBy(i => i.Date) .ToListAsync(); if (id != null) { SacProgramID = id.Value; SacProgram sacProgram = SacProgram.SacPrograms.Where( i => i.ID == id.Value).Single(); SacProgram.Speakers = sacProgram.Speakers; } if (speakerID != null) { SpeakerID = speakerID.Value; //Instructor.Enrollments = SacProgram.Speakers.Where( // x => x.SpeakerID == speakerID).Single().SpeakerName; } }
public async Task <IActionResult> Edit(int id, [Bind("ID,Date,Conducting,OpeningSong,OpeningPrayer,SacramentSong,FirstSpeaker,SecondSpeaker,IntermediateSong,ThirdSpeaker,ClosingSong,ClosingPrayer")] SacProgram sacProgram) { if (id != sacProgram.ID) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(sacProgram); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!SacProgramExists(sacProgram.ID)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(sacProgram)); }
public async Task <IActionResult> Create([Bind("ID,Date,Conducting,OpeningSong,OpeningPrayer,SacramentSong,FirstSpeaker,SecondSpeaker,IntermediateSong,ThirdSpeaker,ClosingSong,ClosingPrayer")] SacProgram sacProgram) { if (ModelState.IsValid) { _context.Add(sacProgram); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(sacProgram)); }
public async Task <IActionResult> OnGetAsync(int?id) { if (id == null) { return(NotFound()); } SacProgram = await _context.SacProgram.FirstOrDefaultAsync(m => m.ID == id); if (SacProgram == null) { return(NotFound()); } return(Page()); }
public async Task <IActionResult> OnPostAsync(int?id) { if (id == null) { return(NotFound()); } SacProgram = await _context.SacProgram.FindAsync(id); if (SacProgram != null) { _context.SacProgram.Remove(SacProgram); await _context.SaveChangesAsync(); } return(RedirectToPage("./Index")); }