public async Task <ActionResult <voter> > Postvoter(voter voter) { _context.voter.Add(voter); await _context.SaveChangesAsync(); return(CreatedAtAction("Getvoter", new { id = voter.Id }, voter)); }
public async Task <IActionResult> Putvoter(int id, voter voter) { if (id != voter.Id) { return(BadRequest()); } _context.Entry(voter).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!voterExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }