Beispiel #1
0
        public async Task<IHttpActionResult> PostOldhamCoup(OldhamCoup oldhamCoup)
        {
            if (!ModelState.IsValid)
            {
                return BadRequest(ModelState);
            }

            db.OldhamCouplings.Add(oldhamCoup);

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

            return CreatedAtRoute("DefaultApi", new { id = oldhamCoup.TypeID }, oldhamCoup);
        }
Beispiel #2
0
        public async Task<IHttpActionResult> PutOldhamCoup(string id, OldhamCoup oldhamCoup)
        {
            if (!ModelState.IsValid)
            {
                return BadRequest(ModelState);
            }

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

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

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

            return StatusCode(HttpStatusCode.NoContent);
        }
        public async Task <IHttpActionResult> PostOldhamCoup(OldhamCoup oldhamCoup)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.OldhamCouplings.Add(oldhamCoup);

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

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

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

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

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

            return(StatusCode(HttpStatusCode.NoContent));
        }
        public async Task <IHttpActionResult> GetOldhamCoup(string id)
        {
            OldhamCoup oldhamCoup = await db.OldhamCouplings.FindAsync(id);

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

            return(Ok(oldhamCoup));
        }
        public async Task <IHttpActionResult> DeleteOldhamCoup(string id)
        {
            OldhamCoup oldhamCoup = await db.OldhamCouplings.FindAsync(id);

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

            db.OldhamCouplings.Remove(oldhamCoup);
            await db.SaveChangesAsync();

            return(Ok(oldhamCoup));
        }