Exemple #1
0
        public IHttpActionResult PostCat_RH(Cat_RH cat_RH)
        {
            if (!ModelState.IsValid)
            {
                return BadRequest(ModelState);
            }

            db.Cat_RH.Add(cat_RH);

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateException)
            {
                if (Cat_RHExists(cat_RH.Id_RH))
                {
                    return Conflict();
                }
                else
                {
                    throw;
                }
            }

            return CreatedAtRoute("DefaultApi", new { id = cat_RH.Id_RH }, cat_RH);
        }
Exemple #2
0
        public IHttpActionResult PutCat_RH(int id, Cat_RH cat_RH)
        {
            if (!ModelState.IsValid)
            {
                return BadRequest(ModelState);
            }

            if (id != cat_RH.Id_RH)
            {
                return BadRequest();
            }

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

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

            return StatusCode(HttpStatusCode.NoContent);
        }