// GET: InviteeTables/Create public async Task <int> RunAlgo() { if (!isDataValid()) { throw new Exception(" "); } result = algo.RunAlgo(AlgoDbCreation()).getGens().ToList(); EventOption eventOption = new EventOption(GetEventByID(MyGlobals.GlobalEventID)); foreach (var item in result) { InviteeTable inviteeTable = new InviteeTable(item.invitee, item.table, eventOption, GetEventByID(MyGlobals.GlobalEventID)); var result = _context.Add(inviteeTable); } var result2 = await _context.SaveChangesAsync(); ViewData["EventId"] = new SelectList(_context.Event, "Id", "Name"); ViewData["EventOptionId"] = new SelectList(_context.EventOption, "Id", "Id"); ViewData["InviteeId"] = new SelectList(_context.Invitee, "Id", "FirstName"); ViewData["TableId"] = new SelectList(_context.Table, "Id", "Id"); ViewData["CurrentEvent"] = MyGlobals.GlobalEventName; return(eventOption.Id); }
public async Task <IActionResult> Create([Bind("Id,InviteeId,TableId,EventOptionId,EventId")] InviteeTable inviteeTable) { if (ModelState.IsValid) { _context.Add(inviteeTable); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["EventId"] = new SelectList(_context.Event.OrderBy(x => x.Name), "Id", "Name", inviteeTable.EventId); ViewData["EventOptionId"] = new SelectList(_context.EventOption, "Id", "Id", inviteeTable.EventOptionId); ViewData["InviteeId"] = new SelectList(_context.Invitee.OrderBy(x => x.FullName), "Id", "FullName", inviteeTable.InviteeId); ViewData["TableId"] = new SelectList(_context.Table, "Id", "Id", inviteeTable.TableId); return(View(inviteeTable)); }
// GET: InviteeTables/Create public async Task <IActionResult> Create() { result = algo.RunAlgo(AlgoDbCreation()).getGens().ToList(); //EventOption eventOption() foreach (var item in result) { InviteeTable inviteeTable = new InviteeTable(item.invitee, item.table, GetEventOptionByID(1), GetEventByID(MyGlobals.GlobalEventID)); var result = _context.Add(inviteeTable); } var result2 = await _context.SaveChangesAsync(); ViewData["EventId"] = new SelectList(_context.Event, "Id", "Name"); ViewData["EventOptionId"] = new SelectList(_context.EventOption, "Id", "Id"); ViewData["InviteeId"] = new SelectList(_context.Invitee, "Id", "FirstName"); ViewData["TableId"] = new SelectList(_context.Table, "Id", "Id"); return(RedirectToAction(nameof(Index))); }