예제 #1
0
        public async Task <IHttpActionResult> PostFlexiblePinCoup(FlexiblePinCoup flexiblePinCoup)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.FlexiblePinCouplings.Add(flexiblePinCoup);

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

            return(CreatedAtRoute("DefaultApi", new { id = flexiblePinCoup.TypeID }, flexiblePinCoup));
        }
예제 #2
0
        public async Task <IHttpActionResult> PutFlexiblePinCoup(string id, FlexiblePinCoup flexiblePinCoup)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

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

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

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

            return(StatusCode(HttpStatusCode.NoContent));
        }
예제 #3
0
        public async Task <IHttpActionResult> GetFlexiblePinCoup(string id)
        {
            FlexiblePinCoup flexiblePinCoup = await db.FlexiblePinCouplings.FindAsync(id);

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

            return(Ok(flexiblePinCoup));
        }
예제 #4
0
        public async Task <IHttpActionResult> DeleteFlexiblePinCoup(string id)
        {
            FlexiblePinCoup flexiblePinCoup = await db.FlexiblePinCouplings.FindAsync(id);

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

            db.FlexiblePinCouplings.Remove(flexiblePinCoup);
            await db.SaveChangesAsync();

            return(Ok(flexiblePinCoup));
        }