コード例 #1
0
        public async Task <IActionResult> PutMstProvince([FromRoute] int id, [FromBody] MstProvince mstProvince)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != mstProvince.ProvinceId)
            {
                return(BadRequest());
            }

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

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

            return(NoContent());
        }
コード例 #2
0
        public async Task <IActionResult> PostMstProvince([FromBody] MstProvince mstProvince)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            _context.MstProvince.Add(mstProvince);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetMstProvince", new { id = mstProvince.ProvinceId }, mstProvince));
        }