コード例 #1
0
        public async Task <ActionResult <DCanidate> > PostDCanidate(DCanidate dCanidate)
        {
            _context.DCanidates.Add(dCanidate);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetDCanidate", new { id = dCanidate.Id }, dCanidate));
        }
コード例 #2
0
        public async Task <IActionResult> PutDCanidate(int id, DCanidate dCanidate)
        {
            dCanidate.Id = id;

            _context.Entry(dCanidate).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!DCanidateExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }