예제 #1
0
        public async Task<IHttpActionResult> PostTaperedRollerBrg(TaperedRollerBrg taperedRollerBrg)
        {
            if (!ModelState.IsValid)
            {
                return BadRequest(ModelState);
            }

            db.TaperedRollerBearings.Add(taperedRollerBrg);

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

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

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

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

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

            return StatusCode(HttpStatusCode.NoContent);
        }