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

            if (id != binder.Id)
            {
                return BadRequest();
            }

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

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

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

            db.Binder.Add(binder);
            await db.SaveChangesAsync();

            return CreatedAtRoute("DefaultApi", new { id = binder.Id }, binder);
        }
예제 #3
0
        // POST: odata/Binders
        public async Task<IHttpActionResult> Post(Binder binder)
        {
            if (!ModelState.IsValid)
            {
                return BadRequest(ModelState);
            }

            db.Binder.Add(binder);
            await db.SaveChangesAsync();

            return Created(binder);
        }