public async Task <IActionResult> Edit(string id, [Bind("Id,VoterId,VoteId")] VoterVotes voterVotes) { if (id != voterVotes.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(voterVotes); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!VoterVotesExists(voterVotes.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["VoteId"] = new SelectList(_context.Votes, "Id", "Title", voterVotes.VoteId); ViewData["VoterId"] = new SelectList(_context.Voters, "Id", "NationalId", voterVotes.VoterId); return(View(voterVotes)); }
public async Task <IActionResult> Create([Bind("Id,VoterId,VoteId")] VoterVotes voterVotes) { if (ModelState.IsValid) { _context.Add(voterVotes); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["VoteId"] = new SelectList(_context.Votes, "Id", "Title", voterVotes.VoteId); ViewData["VoterId"] = new SelectList(_context.Voters, "Id", "NationalId", voterVotes.VoterId); return(View(voterVotes)); }