Ejemplo n.º 1
0
        public IHttpActionResult PutView_State(int id, View_State view_State)
        {
            if (!ModelState.IsValid)
            {
                return BadRequest(ModelState);
            }

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

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

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

            return StatusCode(HttpStatusCode.NoContent);
        }
Ejemplo n.º 2
0
        public IHttpActionResult PostView_State(View_State view_State)
        {
            if (!ModelState.IsValid)
            {
                return BadRequest(ModelState);
            }

            db.View_State.Add(view_State);

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateException)
            {
                if (View_StateExists(view_State.ID))
                {
                    return Conflict();
                }
                else
                {
                    throw;
                }
            }

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