示例#1
0
        public async Task <IActionResult> PutRcaCode([FromRoute] int id, [FromBody] RcaCode rcaCode)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != rcaCode.RcaCodeId)
            {
                return(BadRequest());
            }

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

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

            return(NoContent());
        }
示例#2
0
        public async Task <IActionResult> PostRcaCode([FromBody] RcaCode rcaCode)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            _context.RcaCodes.Add(rcaCode);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetRcaCode", new { id = rcaCode.RcaCodeId }, rcaCode));
        }