Ejemplo n.º 1
0
        public IHttpActionResult PutSpecials(int id, Specials specials)
        {
            if (!ModelState.IsValid)
            {
                return BadRequest(ModelState);
            }

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

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

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!SpecialsExists(id))
                {
                    return NotFound();
                }
                else
                {
                    throw;
                }
            }

            return StatusCode(HttpStatusCode.NoContent);
        }
Ejemplo n.º 2
0
        public IHttpActionResult PostSpecials(Specials specials)
        {
            if (!ModelState.IsValid)
            {
                return BadRequest(ModelState);
            }

            db.Specials.Add(specials);
            db.SaveChanges();

            return CreatedAtRoute("DefaultApi", new { id = specials.ID }, specials);
        }