public async Task <IHttpActionResult> PostFlangeCoup(FlangeCoup flangeCoup)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.FlangeCouplings.Add(flangeCoup);

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

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

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

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

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

            return(StatusCode(HttpStatusCode.NoContent));
        }
Exemplo n.º 3
0
        public async Task<IHttpActionResult> PostFlangeCoup(FlangeCoup flangeCoup)
        {
            if (!ModelState.IsValid)
            {
                return BadRequest(ModelState);
            }

            db.FlangeCouplings.Add(flangeCoup);

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

            return CreatedAtRoute("DefaultApi", new { id = flangeCoup.TypeID }, flangeCoup);
        }
Exemplo n.º 4
0
        public async Task<IHttpActionResult> PutFlangeCoup(string id, FlangeCoup flangeCoup)
        {
            if (!ModelState.IsValid)
            {
                return BadRequest(ModelState);
            }

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

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

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

            return StatusCode(HttpStatusCode.NoContent);
        }
        public async Task <IHttpActionResult> GetFlangeCoup(string id)
        {
            FlangeCoup flangeCoup = await db.FlangeCouplings.FindAsync(id);

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

            return(Ok(flangeCoup));
        }
        public async Task <IHttpActionResult> DeleteFlangeCoup(string id)
        {
            FlangeCoup flangeCoup = await db.FlangeCouplings.FindAsync(id);

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

            db.FlangeCouplings.Remove(flangeCoup);
            await db.SaveChangesAsync();

            return(Ok(flangeCoup));
        }