public async Task <IHttpActionResult> PostCylinRollerBrg(CylinRollerBrg cylinRollerBrg)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.CylinRollerBearings.Add(cylinRollerBrg);

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

            return(CreatedAtRoute("DefaultApi", new { id = cylinRollerBrg.TypeID }, cylinRollerBrg));
        }
        public async Task <IHttpActionResult> PutCylinRollerBrg(string id, CylinRollerBrg cylinRollerBrg)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

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

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

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

            return(StatusCode(HttpStatusCode.NoContent));
        }
Exemple #3
0
        public async Task<IHttpActionResult> PostCylinRollerBrg(CylinRollerBrg cylinRollerBrg)
        {
            if (!ModelState.IsValid)
            {
                return BadRequest(ModelState);
            }

            db.CylinRollerBearings.Add(cylinRollerBrg);

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

            return CreatedAtRoute("DefaultApi", new { id = cylinRollerBrg.TypeID }, cylinRollerBrg);
        }
Exemple #4
0
        public async Task<IHttpActionResult> PutCylinRollerBrg(string id, CylinRollerBrg cylinRollerBrg)
        {
            if (!ModelState.IsValid)
            {
                return BadRequest(ModelState);
            }

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

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

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

            return StatusCode(HttpStatusCode.NoContent);
        }
        public async Task <IHttpActionResult> GetCylinRollerBrg(string id)
        {
            CylinRollerBrg cylinRollerBrg = await db.CylinRollerBearings.FindAsync(id);

            if (cylinRollerBrg == null)
            {
                return(NotFound());
            }

            return(Ok(cylinRollerBrg));
        }
        public async Task <IHttpActionResult> DeleteCylinRollerBrg(string id)
        {
            CylinRollerBrg cylinRollerBrg = await db.CylinRollerBearings.FindAsync(id);

            if (cylinRollerBrg == null)
            {
                return(NotFound());
            }

            db.CylinRollerBearings.Remove(cylinRollerBrg);
            await db.SaveChangesAsync();

            return(Ok(cylinRollerBrg));
        }