コード例 #1
0
        public async Task <ActionResult <voter> > Postvoter(voter voter)
        {
            _context.voter.Add(voter);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("Getvoter", new { id = voter.Id }, voter));
        }
コード例 #2
0
        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());
        }