コード例 #1
0
        public async Task <IActionResult> PutEmechanicalCoupler(short id, EmechanicalCoupler emechanicalCoupler)
        {
            if (id != emechanicalCoupler.EmechanicalCouplerId)
            {
                return(BadRequest());
            }

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

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

            return(NoContent());
        }
コード例 #2
0
        public async Task <ActionResult <EmechanicalCoupler> > PostEmechanicalCoupler(EmechanicalCoupler emechanicalCoupler)
        {
            _context.EmechanicalCoupler.Add(emechanicalCoupler);
            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateException)
            {
                if (EmechanicalCouplerExists(emechanicalCoupler.EmechanicalCouplerId))
                {
                    return(Conflict());
                }
                else
                {
                    throw;
                }
            }

            return(CreatedAtAction("GetEmechanicalCoupler", new { id = emechanicalCoupler.EmechanicalCouplerId }, emechanicalCoupler));
        }