public async Task <IActionResult> Create([Bind("MeetingId,NameSpeaker,Topic")] Talks talks) { if (ModelState.IsValid) { _context.Add(talks); await _context.SaveChangesAsync(); return(RedirectToAction("EditSpeakers", "Meetings", new { id = talks.MeetingId })); } return(View(talks)); }
public async Task <IActionResult> Create([Bind("Id,Date,ConductingLeader,OpeningHymn,Invocation,SacramentHymn,IntermediateHymn,ClosingHymn,Benediction")] Meeting meeting) { var dateMeeting = await _context.Meeting .Include(s => s.Talks) .AsNoTracking() .FirstOrDefaultAsync(m => m.Date == meeting.Date); if (dateMeeting != null) { ModelState.AddModelError(string.Empty, "There exists a register for this date"); } if (ModelState.IsValid) { _context.Add(meeting); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(meeting)); }