Beispiel #1
0
        public async Task<IHttpActionResult> PutHeader(int id, Header header)
        {
            if (!ModelState.IsValid)
            {
                return BadRequest(ModelState);
            }

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

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

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

            return StatusCode(HttpStatusCode.NoContent);
        }
Beispiel #2
0
        public async Task<IHttpActionResult> PostHeader(Header header)
        {
            if (!ModelState.IsValid)
            {
                return BadRequest(ModelState);
            }

            db.Headers.Add(header);
            await db.SaveChangesAsync();

            return CreatedAtRoute("DefaultApi", new { id = header.Id }, header);
        }