示例#1
0
        public async Task <IHttpActionResult> PutInfoSup(int id, InfoSup infoSup)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != infoSup.idInfo)
            {
                return(BadRequest());
            }

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

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

            return(StatusCode(HttpStatusCode.NoContent));
        }
示例#2
0
        public async Task <IHttpActionResult> GetInfoSup(int id)
        {
            InfoSup infoSup = await db.InfoSups.FindAsync(id);

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

            return(Ok(infoSup));
        }
示例#3
0
        public async Task <IHttpActionResult> PostInfoSup(InfoSup infoSup)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.InfoSups.Add(infoSup);
            await db.SaveChangesAsync();

            return(CreatedAtRoute("DefaultApi", new { id = infoSup.idInfo }, infoSup));
        }
示例#4
0
        public async Task <IHttpActionResult> DeleteInfoSup(int id)
        {
            InfoSup infoSup = await db.InfoSups.FindAsync(id);

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

            db.InfoSups.Remove(infoSup);
            await db.SaveChangesAsync();

            return(Ok(infoSup));
        }