public async Task <IActionResult> Edit(int id, [Bind("Id,MainInviteeId,SecondaryInviteeId,IsSittingTogether,EventId,EventOptionId")] PersonalRestriction personalRestriction) { personalRestriction.EventId = MyGlobals.GlobalEventID; if (id != personalRestriction.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(personalRestriction); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!PersonalRestrictionExists(personalRestriction.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["EventId"] = new SelectList(_context.Event, "Id", "Name", personalRestriction.EventId); ViewData["MainInviteeId"] = new SelectList(_context.Invitee.OrderBy(x => x.FullName), "Id", "FullName", personalRestriction.MainInviteeId); ViewData["SecondaryInviteeId"] = new SelectList(_context.Invitee.OrderBy(x => x.FullName), "Id", "FullName", personalRestriction.SecondaryInviteeId); return(View(personalRestriction)); }
public async Task <IActionResult> Create([Bind("Id,MainInviteeId,SecondaryInviteeId,IsSittingTogether,EventId,EventOptionId")] PersonalRestriction personalRestriction) { personalRestriction.EventId = MyGlobals.GlobalEventID; if (ModelState.IsValid) { _context.Add(personalRestriction); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["EventId"] = new SelectList(_context.Event, "Id", "Name", personalRestriction.EventId); ViewData["MainInviteeId"] = new SelectList(_context.Invitee.OrderBy(x => x.FullName), "Id", "FullName", personalRestriction.MainInviteeId); ViewData["SecondaryInviteeId"] = new SelectList(_context.Invitee.OrderBy(x => x.FullName), "Id", "FullName", personalRestriction.SecondaryInviteeId); return(View(personalRestriction)); }