예제 #1
0
        public async Task<IHttpActionResult> PostSpindleSrvMotorPara(SpindleSrvMotorPara spindleSrvMotorPara)
        {
            if (!ModelState.IsValid)
            {
                return BadRequest(ModelState);
            }

            db.SpindleSrvMotorParas.Add(spindleSrvMotorPara);

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

            return CreatedAtRoute("DefaultApi", new { id = spindleSrvMotorPara.TypeID }, spindleSrvMotorPara);
        }
예제 #2
0
        public async Task<IHttpActionResult> PutSpindleSrvMotorPara(string id, SpindleSrvMotorPara spindleSrvMotorPara)
        {
            if (!ModelState.IsValid)
            {
                return BadRequest(ModelState);
            }

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

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

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

            return StatusCode(HttpStatusCode.NoContent);
        }