Beispiel #1
0
        public IHttpActionResult PutUsers(decimal id, TEST_USERS test_users)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

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

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

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

            return(StatusCode(HttpStatusCode.NoContent));
        }
Beispiel #2
0
        public IHttpActionResult PostUser(TEST_USERS tEST_USERS)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.TEST_USERS.Add(tEST_USERS);

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

            return(CreatedAtRoute("DefaultApi", new { id = tEST_USERS.ID }, tEST_USERS));
        }
Beispiel #3
0
        public IHttpActionResult GetUser(decimal id)
        {
            TEST_USERS tEST_USERS = db.TEST_USERS.Find(id);

            if (tEST_USERS == null)
            {
                return(NotFound());
            }

            return(Ok(tEST_USERS));
        }
Beispiel #4
0
        public IHttpActionResult DeleteUser(decimal id)
        {
            TEST_USERS tEST_USERS = db.TEST_USERS.Find(id);

            if (tEST_USERS == null)
            {
                return(NotFound());
            }

            db.TEST_USERS.Remove(tEST_USERS);
            db.SaveChanges();

            return(Ok(tEST_USERS));
        }