Exemple #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);
        }
Exemple #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);
        }
Exemple #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));
        }
Exemple #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));
        }
Exemple #5
0
        public async Task <IHttpActionResult> GetSpindleBeltLength(int id)
        {
            SpindleBeltLength spindleBeltLength = await db.SpindleBeltLengths.FindAsync(id);

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

            return(Ok(spindleBeltLength));
        }
Exemple #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));
        }