public async Task <IActionResult> Edit(int id, [Bind("UserMain_EventId,Attend,UserMainId,EventId")] UserMain_Event userMain_Event) { if (id != userMain_Event.UserMain_EventId) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(userMain_Event); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!UserMain_EventExists(userMain_Event.UserMain_EventId)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["EventId"] = new SelectList(_context.Event, "UserId", "UserId", userMain_Event.EventId); ViewData["UserMainId"] = new SelectList(_context.UserMain, "UserId", "UserId", userMain_Event.UserMainId); return(View(userMain_Event)); }
public async Task <IActionResult> Create([Bind("UserMain_EventId,Attend,UserMainId,EventId")] UserMain_Event userMain_Event) { if (ModelState.IsValid) { _context.Add(userMain_Event); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["EventId"] = new SelectList(_context.Event, "UserId", "UserId", userMain_Event.EventId); ViewData["UserMainId"] = new SelectList(_context.UserMain, "UserId", "UserId", userMain_Event.UserMainId); return(View(userMain_Event)); }