コード例 #1
0
        public async Task <IActionResult> PutRollingstock(short id, Rollingstock rollingstock)
        {
            if (id != rollingstock.RollingstockId)
            {
                return(BadRequest());
            }

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

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

            return(NoContent());
        }
コード例 #2
0
        public async Task <ActionResult <Rollingstock> > PostRollingstock(Rollingstock rollingstock)
        {
            _context.Rollingstock.Add(rollingstock);
            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateException)
            {
                if (RollingstockExists(rollingstock.RollingstockId))
                {
                    return(Conflict());
                }
                else
                {
                    throw;
                }
            }

            return(CreatedAtAction("GetRollingstock", new { id = rollingstock.RollingstockId }, rollingstock));
        }