コード例 #1
0
        public async Task<IHttpActionResult> PostNCSystemFunctionalOption(NCSystemFunctionalOptions nCSystemFunctionalOptions)
        {
            if (!ModelState.IsValid)
            {
                return BadRequest(ModelState);
            }

            db.NCSystemFunctionalOptions.Add(nCSystemFunctionalOptions);

            try
            {
                await db.SaveChangesAsync();
            }
            catch (DbUpdateException)
            {
                if (NCSystemFunctionalOptionsExists(nCSystemFunctionalOptions.TypeID))
                {
                    return Conflict();
                }
                else
                {
                    throw;
                }
            }

            return CreatedAtRoute("DefaultApi", new { id = nCSystemFunctionalOptions.TypeID }, nCSystemFunctionalOptions);
        }
コード例 #2
0
        public async Task<IHttpActionResult> PutNCSystemFunctionalOption(string id, NCSystemFunctionalOptions nCSystemFunctionalOptions)
        {
            if (!ModelState.IsValid)
            {
                return BadRequest(ModelState);
            }

            if (id != nCSystemFunctionalOptions.TypeID)
            {
                return BadRequest();
            }

            db.Entry(nCSystemFunctionalOptions).State = EntityState.Modified;

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

            return StatusCode(HttpStatusCode.NoContent);
        }