예제 #1
0
        public async Task <IHttpActionResult> PutScoccer(int id, Scoccer scoccer)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != scoccer.ID)
            {
                return(BadRequest());
            }

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

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

            return(StatusCode(HttpStatusCode.NoContent));
        }
예제 #2
0
        public async Task <IHttpActionResult> PostScoccer(Scoccer scoccer)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.scoccer.Add(scoccer);
            await db.SaveChangesAsync();

            return(CreatedAtRoute("DefaultApi", new { id = scoccer.ID }, scoccer));
        }
예제 #3
0
        public async Task <IHttpActionResult> DeleteScoccer(int id)
        {
            Scoccer scoccer = await db.scoccer.FindAsync(id);

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

            db.scoccer.Remove(scoccer);
            await db.SaveChangesAsync();

            return(Ok(scoccer));
        }