Ejemplo n.º 1
0
        public IHttpActionResult PutWelness(int id, Welness welness)
        {
            if (!ModelState.IsValid)
            {
                return BadRequest(ModelState);
            }

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

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

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

            return StatusCode(HttpStatusCode.NoContent);
        }
Ejemplo n.º 2
0
        public IHttpActionResult PostWelness(Welness welness)
        {
            if (!ModelState.IsValid)
            {
                return BadRequest(ModelState);
            }

            db.Welnesses.Add(welness);
            db.SaveChanges();

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