Example #1
0
        public async Task<IHttpActionResult> PostSpindleBeltLength(SpindleBeltLength spindleBeltLength)
        {
            if (!ModelState.IsValid)
            {
                return BadRequest(ModelState);
            }

            db.SpindleBeltLengths.Add(spindleBeltLength);

            try
            {
                await db.SaveChangesAsync();
            }
            catch (DbUpdateException)
            {
                if (SpindleBeltLengthExists(spindleBeltLength.LengthID))
                {
                    return Conflict();
                }
                else
                {
                    throw;
                }
            }

            return CreatedAtRoute("DefaultApi", new { id = spindleBeltLength.LengthID }, spindleBeltLength);
        }
Example #2
0
        public async Task<IHttpActionResult> PutSpindleBeltLength(int id, SpindleBeltLength spindleBeltLength)
        {
            if (!ModelState.IsValid)
            {
                return BadRequest(ModelState);
            }

            if (id != spindleBeltLength.LengthID)
            {
                return BadRequest();
            }

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

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

            return StatusCode(HttpStatusCode.NoContent);
        }
Example #3
0
        public async Task <IHttpActionResult> PostSpindleBeltLength(SpindleBeltLength spindleBeltLength)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.SpindleBeltLengths.Add(spindleBeltLength);

            try
            {
                await db.SaveChangesAsync();
            }
            catch (DbUpdateException)
            {
                if (SpindleBeltLengthExists(spindleBeltLength.LengthID))
                {
                    return(Conflict());
                }
                else
                {
                    throw;
                }
            }

            return(CreatedAtRoute("DefaultApi", new { id = spindleBeltLength.LengthID }, spindleBeltLength));
        }
Example #4
0
        public async Task <IHttpActionResult> PutSpindleBeltLength(int id, SpindleBeltLength spindleBeltLength)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != spindleBeltLength.LengthID)
            {
                return(BadRequest());
            }

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

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

            return(StatusCode(HttpStatusCode.NoContent));
        }
Example #5
0
        public async Task <IHttpActionResult> GetSpindleBeltLength(int id)
        {
            SpindleBeltLength spindleBeltLength = await db.SpindleBeltLengths.FindAsync(id);

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

            return(Ok(spindleBeltLength));
        }
Example #6
0
        public async Task <IHttpActionResult> DeleteSpindleBeltLength(int id)
        {
            SpindleBeltLength spindleBeltLength = await db.SpindleBeltLengths.FindAsync(id);

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

            db.SpindleBeltLengths.Remove(spindleBeltLength);
            await db.SaveChangesAsync();

            return(Ok(spindleBeltLength));
        }